Last Updated: 23 Jan 2024
|
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
backend-tech:php:best-practices [May 11, 2009 06:47 AM] dordal |
backend-tech:php:best-practices [Jan 23, 2024 09:34 AM] 114.119.150.49 old revision restored (Jan 19, 2024 04:26 PM) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | = PHP Best Practices = | ||
+ | == Leave the slash (/) off URLs, file paths, etc. == | ||
+ | |||
+ | At some point, you'll probably need to create constants with URLs or file paths. It's rather tempting to put a closing slash on the end, because it looks 'more complete', | ||
+ | <code php> | ||
+ | // don't include trailing slashes in URL or path constants | ||
+ | define(' | ||
+ | define(' | ||
+ | </ | ||
+ | |||
+ | == Use Native Database Extensions, not PDO, etc. == | ||
+ | |||
+ | I generally recommend you use native PHP database extensions, and not an abstraction layer like PDO. Read why on the [[mysqli-vs-pgsql-vs-pdo-vs-zend_db|pgsql vs. mysqli vs. PDO vs. Zend_DB]] page. |