This code can run. the PHPcodeclassFoo {constfoo = 'bar'; public $ foo = 'foobar'; constbar = 'foo'; static $ bar = 'foobar ';} var_dump (foo ::$ ba this code can run and crash
PHP code
class Foo{ const foo='bar'; public $foo='foobar'; const bar='foo'; static $bar='foobar';}var_dump(foo::$bar); // static propertyvar_dump(foo::bar); // class constant$bar = new Foo();var_dump($bar->foo); // object propertyvar_dump(bar::foo); // class constant
It's strange. I am confused. how can I output it ??
------ Solution --------------------
Why not.
------ Solution --------------------
Why not.
------ Solution --------------------
Except var_dump (bar: foo); // class constant, the bar class is undefined, and the rest are normal. What do you think?
------ Solution --------------------
It's running.
------ Solution --------------------
1. variable names are case sensitive
1
2 $ abc = 'abc ';
3 echo $ abc; // output 'ABC'
4 echo $ aBc; // no output
5 echo $ ABC; // no output
2. constant names are case-sensitive by default and are generally written in uppercase.
(But the default configuration item cannot be changed)
3. the function name, method name, and class name are case-insensitive.
However, we recommend that you use the same name as the one defined in the definition.
1
2 function show (){
3 echo "Hello World ";
4}
5 show (); // output the recommended Hello World statement
6 SHOW (); // output Hello World
Class cls {
Static function func (){
Echo "hello world ";
}
}
8 Cls: FunC (); // output hello world
4. magic constants are case-insensitive and are recommended to be capitalized.
Including: __line _, _ FILE _, _ DIR _, _ FUNCTION _, _ CLASS _, _ METHOD _, and _ NAMESPACE __.
5. NULL, TRUE, and FALSE are case insensitive.