This code can run and crash.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.