First knowledge of PHP (a) Basic grammar, the first knowledge of PHP basic Grammar _php Tutorial

Source: Internet
Author: User

First Knowledge of PHP (i) basic grammar, the first knowledge of PHP basic grammar


Always ready to learn PHP, the results of a period of time there is always something, delayed for a while. Hurry up and catch up now!

This series just talk about my comments on PHP, not the nature of the tutorial. In addition, I am a small white, just write essays, the Great God for a pat. I have studied C, Java, Python, and touched some HTML. If you have a similar experience with my friends want to contact PHP if you can provide some ideas, it would be better.

In my opinion, PHP has a thick HTML style, which is really worthy of being born for the Web programming. One of the biggest features is the way variables are used. In languages such as C,python, a variable is a number of characters that are called directly by name, such as the classic for (i=0;i<50;i++). But PHP is much closer to HTML in the way the variables are handled, the characters that are written directly are considered strings, and the use of variables requires $ to start with: for ($i =0; $i <50; $i + +) It makes me very uncomfortable, I think it would be very troublesome to write this way. But seeing the processing of strings, I found that this has the advantage:

The concatenation of strings in PHP can be done using "," like Python, such as:

  $a=' Bob ';
echo "Hello",$a;

Results such as:

$a=' Bob ';
echo "Hello". $a;

The result is the same:

$a=' Bob ';
echo "Hello $a";

is still the same result:

 

  This is the unique style of PHP.

Another feature is the array in PHP. An array of PHP. The array of PHP seems to me to be a collection of Python lists and dictionaries. For the stored data, he does not like the array of C need to declare the type, regardless of the shape or string can be mixed stored in the same group of "peaceful coexistence"; He also supports the use of strings to index the usage of traditional arrays, which can be indexed using a string, which is very much like a python dictionary. It is a particularly strange thing, but it is particularly convenient to think carefully.

$arr = array ( 0 => + , ' G ' => ' GGG ' , 1 => ' www ' , ' h ' => ' HHH ' );
Print_r ( $arr );

    For example, arr is an array that holds four elements, No. 0 is integer 50, the next element is a string GGG, uses the character "G" index, the third element is the 1th element string www, and the fourth element is a string hhh, using the character "H" index.

Next, use the array_push function to append a string element to the array after www

$ Arr = array ( 0 => + , ' G ' => ' GGG ' , 1 => ' www ' , ' h ' => ' HHH ' );
Array_push ( $arr , ' www ' );
Print_r ( $arr );

span> span> For example, the appended element is the fifth element, but continues to sort using index 2nd.

That's how I feel about PHP's basic syntax.

http://www.bkjia.com/PHPjc/1117675.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117675.html techarticle First knowledge of PHP (a) Basic grammar, the first knowledge of PHP basic grammar has been prepared to learn PHP, the results of a period of time there is always something, delayed for a while. Hurry up and catch up now! This series is just about ...

  • 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.