PHP basic statements and functions

WBOY
Release: 2016-07-28 08:28:42
Original
916 people have browsed it

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>
Copy after login

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>
Copy after login
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>
Copy after login

use (take the first element):

<code><span>$tests</span>[<span>0</span>];</code>
Copy after login

(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>
Copy after login

use (take the first element):

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

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!