You are here: Re: Programming Tips and Tricks « PHP Programming Language « IT news, forums, messages
Re: Programming Tips and Tricks

Posted by Michael Phipps on 11/15/89 11:22

> I just wondered what tips and tricks people have out there that they
> think other people might benefit from.

ALWAYS code as if register_globals is off. In other words if you use:

use $_GET['id'] instead of $id to get myscript.php?id=1234
You're going to hate it if you've been coding the as if register_globals is
on and your hosting provider upgrades and register_globals gets switched
off.
----
Use $_SERVER['DOCUMENT_ROOT'] when pointing at files.
Your home directory could change when you have to move hosting providers

eg on current server a file may be located at:

on new server it might become:
/www/hosts/user/sitename.com/include/myincludefile.php

By using $_SERVER['DOCUMENT_ROOT'] your code will not have to change.

$_SERVER['DOCUMENT_ROOT'].'/include/myincludefile.php'
---
Check out Smarty Templates

http://smarty.php.net

It separates your php code from design html, so all you have to worry about
is getting information to be put into the page. It makes it easier to work
with a designer. I only use echo and print statements for debugging these
days - and I haven't looked back - it is awesome

---

Work offline on a local machine with a webserver and database running - it's
quicker and safer (you can backup) than working on a remote server, or
*horror* - the live site.

---

Use a program like syncrhonex that does incremental ftp - saves hours of
uploading files that haven't changed, particularly if you are on a slow
connection.

----

Take a look at SQLyog at http://www.webyog.com/. After you see the HTTP/
SSH Tunneling you'll throw PHP My Admin away forever - and when you see Data
Syncrhonization and Schema Synchronization - you'll instinctively start
reaching for this tool. SQLyog costs money, but it's worth it. MySQL also
has free gui management tools these days, but it isn't quite as good.

---

If you're on your local machine, and a script isn't running do a syntax
check using php -l filename.php (that's an L for larry) - you'll quickly see
if the error is in syntax. (I develop on a windows box - forgive me if this
is different on *nix)

---

Thats some. OH and if anyone knows a good PHP IDE with a PHP Debugger that
works let me know - I always have problems with server variables in the
debuggers I have tried, but maybe I just aren't using them right.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация