PHP details 1 variable variables and some details

Source: Internet
Author: User

Examples of mutable variables
1<?PHP2 classFoo {3     var $bar= ' I am bar. ';4     var $arr=Array(' I am A. ', ' I am B. ', ' I am C. '));5     var $r= ' I am r. ';6 }7 8 $foo=Newfoo ();9 $bar= ' Bar ';Ten $baz=Array(' foo ', ' Bar ', ' baz ', ' Quux ')); One Echo $foo-$bar. "\ n"; A Echo $foo-$baz[1]. "\ n"; -  - $start= ' B '; the $end= ' AR '; - Echo $foo->{$start.$end} . "\ n"; -  - $arr= ' arr '; + Echo $foo-$arr[1]. "\ n"; - Echo $foo->{$arr}[1]. "\ n"; +  A?>
View Code

Last shown as

1 I am Bar. 2 I am Bar. 3 I am Bar. 4 I am R. 5 I am B.
View Code

Single && double quotation marks

Single quotes: Unlike double quotes and HEREDOC syntax structures, the escape sequences of variables and special characters in single-quote strings will not be replaced.

Examples are

1<?PHP2 3     $s= "Ideone";4     $s 1= ' \\Hello world $s ';//output to \hello world $s5     $s 2= "\\Hello World &&$s";//output for \hello world && Ideone6     Echo $s 1;7     Echo $s 2;8     9     //In addition, the nested part of a string that resembles a self-nesting is not iterative but empty .Ten     $s 3= "Hello World"$s 3";//Output as Hello world One     Echo $s 3; A?>
View Code

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.