case 1:
Action to execute
break;
case 2:
Action to execute
break;
default:
default action
break;
}
Call to function - When calling the function, between the function name, the opening and first parentheses should be written immediately, without spaces; Add a space between a comma and each parameter, and there is no space between the last parameter, closing brackets and semicolons. Here's an example:
$ var = foo ($ bar, $ baz, $ quux);
Function definition - Declare the function by "BSD / Allman style".
function fooFunction ($ arg1, $ arg2 = '') {
if (thing_kien) {
command to execute
}
return $ val;
}
Comment - Comment in C (/ /) language and in C ++ (//) standard both OK. The use of Perl / shell (#) style comments is not recommended.
PHP code card - Always use To determine the scope of PHP code, do not use abbreviations .
Variable name:
Creating Reentrant functions - Functions should not contain static variables but prevent a function from being reentrant.
Align declarative blocks - The declaration block should be aligned.
One command per line - There should only be one statement per line, unless the statements are very closely related.
Short functions and methods - Methods should be limited to one code page.
There may be many guidelines, other rules are mentioned when writing code in PHP. Ideally, all these rules and guidelines should be consistent throughout the code process and this only happens when you follow certain code standards. You can have your own standard if you like to make a difference.
Follow tutorialspoint
Previous article: Upload File in PHP
Next article: Variable predefined in PHP