在PHP中,變量賦值的方法有以下幾種:
$name = "John";
$name1 = "John";
$name2 = &$name1;
$var = "name";
$$var = "John";
$colors = array("red", "green", "blue");
class Person {
public $name;
}
$person = new Person();
$person->name = "John";
$name = null;
這些是PHP中常用的變量賦值方法,根據不同的需求和場景,可以選擇適合的方法來賦值給變量。