Home >Backend Development >PHP Tutorial >PHP basic statements and functions

PHP basic statements and functions

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-28 08:28:42944browse

The following is a summary of my PHP learning today, for reference only

1. Basic structure of PHP:

<code><span><span><?php</span>……
  <span>?></span></span></code>

2. Summary of PHP variable issues:
1. To declare and use variables, you need to add '$' before the variable name

2. Except for static variables, variables declared outside functions can only be used outside the function, and variables declared within the function can only be used within the function

3. global: take variables outside the function and use them inside the function
For example:

 PHP基本语句和函数

4. static: The defined variables can be used both inside and outside the function.
For example, declare a global variable 1. Output statements: staic $x;

<code><span>echo</span><span>""</span>;</code>
can be written in multiple parallels, but except for the last output statement, all others must be followed by a semicolon. In order to avoid errors, you can add a semicolon to each sentence.

2. The plus sign for adding characters in PHP is changed to '.'


3. The declaration and usage methods are the same as js

4. if...else, switch, while, for are not much different from java

5. Array

(1), ordinary array:

<code><span>$tests</span>=<span>array</span>(<span>"test1"</span>,<span>"test2"</span>,<span>"test3"</span>);</code>

use (take the first element):

<code><span>$tests</span>[<span>0</span>];</code>

(2), key-value pair array:

<code><span>$tests</span>=<span>array</span>(<span>"ket1"</span>=><span>"test1"</span>,<span>"ket2"</span>=><span>"test2"</span>,<span>"ket3"</span>=><span>"test3"</span>);</code>

use (take the first element):

<code><span>$tests</span>[<span>'key1'</span>];</code>

If you don’t understand something, you can directly read w3cschool

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i

').text(i)); }; $numbering.fadeIn(1700); }); });


The above has introduced the basic statements and functions of PHP, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn