Home >Backend Development >PHP Tutorial >PHP basic statements and functions
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:
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); }); });