Home > Backend Development > PHP Tutorial > PHP file format specification

PHP file format specification

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-08 09:22:22
Original
1798 people have browsed it

PHP file format specification

PHP specification

1. if…else… way of writing

<code>if (true) {
    // Code here...
} else {
    // Code here...
}

注意: if 与()保持一个空格,
        () 与 { 在同一行,且保持一个空格
</code>
Copy after login

2. if…elseif…else way of writing

<code>if (true) {
    // Code here...
} elseif (true) {
    // Code here...
} else {
    // Code here...
}
</code>
Copy after login

 Old

1. For files that only contain php code, we will write it in the file Ignore the "?>" at the end. This is to prevent extra spaces or other characters from affecting the code. Break a new line at the end of the code file and end it with // end

<code>例:
<?php
$localtime = date('y-m-d H:i:s',time());
$test = 'test';
echo $localtime.$test;
...

// end
</code>
Copy after login

2. Indentation should be able to reflect the logical results of the code. Use TAB for indentation. Leave gaps (add spaces) before and after each statement and the beginning of the brace.

<code>例:
<?php
$t = date("H");

if ($t<20) {
    echo 'Have a good day!';    
} else {
    echo 'Good night';
}
...

// end
</code>
Copy after login

The above introduces the PHP file format specifications, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template