Language and development rules: Difference between revisions

Jump to navigation Jump to search
m
→‎PHP: test subtitles
m (→‎PHP: test subtitles)
Line 40: Line 40:
*Usage of PHP superglobals variables must use the dedicated operators $_COOKIES, $_SERVER, $_ENV but use the Dolibarr function GETPOST() to get the contents of $_GET or $_POST..
*Usage of PHP superglobals variables must use the dedicated operators $_COOKIES, $_SERVER, $_ENV but use the Dolibarr function GETPOST() to get the contents of $_GET or $_POST..


* Other operators ($HTTP_SERVER_GET, ...) are now deprecated in PHP, so they must not be used. Code must work if option '''register_long_arrays''' is set to off. Moreover, the code must work when PHP option '''register_globals''' is off (recommended by PHP). It must also work the if the option '''register_globals''' is on (by default on a lot of installations).
*Other operators ($HTTP_SERVER_GET, ...) are now deprecated in PHP, so they must not be used. Code must work if option '''register_long_arrays''' is set to off. Moreover, the code must work when PHP option '''register_globals''' is off (recommended by PHP). It must also work the if the option '''register_globals''' is on (by default on a lot of installations).


*Do not use '''<s>PHP_SELF</s>'''. Use instead '''$_SERVER["PHP_SELF"]'''. Also, Dolibarr framework sanitizes content of $_SERVER["PHP_SELF"] variable (into main.inc.php file, before any business code).
*Do not use '''<s>PHP_SELF</s>'''. Use instead '''$_SERVER["PHP_SELF"]'''. Also, Dolibarr framework sanitizes content of $_SERVER["PHP_SELF"] variable (into main.inc.php file, before any business code).
Line 57: Line 57:
which is slower.
which is slower.


*Strings must be delimited by a single or double quote and a variable within the string must be outside of the quote.
*'''Strings''' must be delimited by a single or double quote and a variable within the string must be outside of the quote.


<source lang="php">
<source lang="php">
print 'My text show my '.$variable.' !';
print 'My text show my '.$variable.' !';
</source>
</source>
==== Comments ====


*Comments must use the C syntax, ie a double slash for a comment on one line and a slash-star to open a bloc for several lines
*Comments must use the C syntax, ie a double slash for a comment on one line and a slash-star to open a bloc for several lines
Line 84: Line 86:
}
}
</source>
</source>
<br />


*Functions must return a value equal or higher than 0 if successful and strictly lower than 0 if error.
*Functions must return a value equal or higher than 0 if successful and strictly lower than 0 if error.
1,988

edits

Navigation menu