PHP learning notes.

Source: Internet
Author: User

Notes you encounter when learning PHP.

 

String connector in PHP

 

The string connector in PHP uses the dot '.'

For example:

$ A = 'a ';
$ B = 'bb ';
Echo ('a + B = '. $ A. $ B );

 

Output result: PhP output test a + B = AABB

 

Extra points ';' are required for the end of each line in PHP. Otherwise, an error is returned.

Example

$ A = 'a'; $ B = 'bb ';

Or

$ A = 'a ';

$ B = 'bb ';

 

For example

$ A = 'a ';

$ B = 'bb'

The last line does not have a plus sign ';'. Although no error is reported, the write format is not standard.

 

 

Difference between single quotation marks ''and double quotation marks" "in PHP

Double quotation marks: everything in double quotation marks must be escaped. When a variable is replaced,/N,/t, and so on are all escape characters.

Single quotes: all the items in single quotes are output as is, so you don't have to worry about what is in them, what is in it, and what is output.

Differences between echo (), print (), and print_r ()

1. Echo is the syntax, output one or more strings, and no return value;

2. Print is a function that cannot output arrays and objects. Output a string and print have returned values;

3. print_r is a function that can output arrays. Enter all the content of an array in the format of Array (Key => value)
Print_r can output stirng, Int, float, array, object, etc. The output array is represented by a structure,
True is returned when the print_r output is successful. In addition, print_r can use print_r ($ STR, true) to make print_r output and return the value after print_r processing.

For Echo and print, most of them use echo, because it is more efficient than print.

 

 

What do the '&', '$', '->' symbols in PHP mean?

& There are two types
1. Bit operations, binary
For example
The result of 4 & 5 is 4.
Equivalent to binary 100 & 101 equals 100

2. Get the address (equivalent to a pointer)
For example
$ A = 3;
$ B = & $;
$ B = 4;
Echo $;
Output 4

$ Is a variable character. All PHP variables must start with $.

-> is object-oriented, equivalent to Java. symbol
for example
$ A = new myclass ();
$ A-> showme ();
$ A is an object of the myclass class.
In the second sentence, call the showme () method in the myclass.

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.