PHP syntax. PHP basic syntax looks familiar. Running result: Hello, World! The variable is marked as "$ ". You can also set "Hello, World !" Write the following code: concatenating strings is the basic PHP syntax that looks familiar to you. Running result: Hello, World! The variable is marked as "$ ". You can also set "Hello, World !" Write the following code: The concatenation of strings is marked with "." (an English period). Other operators related to numbers are as expected: Running result: Hello 6 people! PHP has complete operators, and their functions are the same as you expected-especially when you have a knowledge background in C or C ++. A good rule of thumb when using PHP is: "If you have any problems, try it first. it is very likely that it will succeed ." Just like Perl, a string is enclosed in double quotation marks, which will replace the variables with values. if it is enclosed in single quotation marks, it will not. Therefore, the following code: Running result: Hello, susanner! Hello, $ name! Note that "" in the string is a line break, just like Perl or C. However, this is only valid in strings enclosed in double quotes. Variable PHP can use environment variables as common variables. This includes the environment variables set by the server for a CGI program (even when you execute PHP in a module mode ). Therefore, if the page is http://www.domain.com/farm/cattle/cow-cow.cow.htmlpacket, use the following code: It will output the [/farm/cattle/cow-cow-cow.html] array using square brackets ([and]) to set the array index (generally or correlated): $ fruit [0] = banana; $ fruit [1] = papaya; $ favorites [animal] = turtle; $ favorites [monster] = cookie; if you assign values to the array, but the index is blank, PHP will place the object at the end of the array. The above variable $ fruit declaration has the same result as the following code: $ fruit [] = banana; $ fruit [] = papaya; you can also use multi-dimensional arrays: $ people [David] [shirt] = blue; $ people [David] [car] = minivan; $ people [Adam] [shirt] = white; $ people [Adam] [car] = sedan; an easy way to create an array is to use the array () function: $ fruit = array (banana, papaya ); $ favorites = array (animal => turtle, monster => cookie); or $ people = array (David => array (shirt => blue, car => minivan ), adam => array (shirt => w Hite, car => sedan); the built-in function count () shows the number of elements in a group: $ fruit = array (banana, papaya); print count ($ fruit ); expected Result 2 is displayed. you can use the loop structure such as for and while: for ($ I = 4; $ I <8; $ I ++) {print "I have eaten $ I bagels today. ";} result I have eaten 4 bagels today. I have eaten 5 bagels today. I have eaten 6 bagels today. I have eaten 7 bagels today. it can also be written as $ I = 4; while ($ I <8) {print "I have eaten $ I bagels today. "; $ I ++;} You can use The control structure if and elseif: if ($ user_count> 200) {print "The site is busy right now! ";} Elseif ($ user_count> 100) {print" The site is sort of active right now! "; Else {print" The site is lonely-only $ user_count user logged on. ";} empirical rules using operators can also be applied to The control structure. You can also use switch, do... while, or even?: Structure.
Http://www.bkjia.com/PHPjc/531893.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/531893.htmlTechArticlePHP basic syntax looks familiar. Running result: Hello, World! The variable is marked as "$ ". You can also set "Hello, World !" Write the following code: the concatenation of strings is...