Community Forums

Important Notice:

Two sections of this forum are available only to registered customers. In order to receive access to the Customer Forums and ResellerCentral Forums, you must first register on these forums or login to your existing forum account. If you are an existing HostNine customer, be sure to register using the email address on file for your billing profile.

Go Back   HostNine Community Forums > H9 General Forums > Lounge / Off Topic > Web Development

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2008, 04:32 AM
adsejam adsejam is offline
Junior Guru Wannabe
 
Join Date: May 2008
Location: UK
Posts: 87
Cool PHP Starter Pack - Fundamental PHP Know-How

Install a local server (for testing purposes):

A local development server is essential to test out your work. GNU/Linux & BSD (except mac) usually have a web server already set up. For others, there are lots of options with php/mysql/apache in a single, easy to install package. I use easyphp. Other options at:

http://www.hotscripts.com/PHP/Softwa...allation_Kits/

php.ini settings

Once you've installed php/mysql/apache, I'd recommend checking the following in your php.ini file:

error_reporting = E_ALL
display_errors = On
register globals off (it's off by default for php v4.2+)
magic_quotes_gpc - see notes, below
magic_quotes_runtime - off

Mac users may find that they don't have a php.ini to edit. See these forum topics: http://forums.devnetwork.net/viewtopic.php?t=11017
http://forums.devnetwork.net/viewtopic.php?t=3916).

Note that you should turn the error reporting level down on a live site to avoid giving out information about your scripts or db structure which a hacker might try to exploit.

Register globals on can potentially create a security risk. If you have any undefined vars/indexes in the script, a site visitor can set them to any value they like (more here). However if you develop with E_ALL you will (presumably) have identified any such and dealt with them, so register globals on would not create any security issues.

Many hosts keep reg globals on for backwards compatibility. Scripts developed with reg globals off will work OK in a reg globals on environment - but not vice versa. So, quite apart from possible security issues, it's better to develop with reg globals off. One day your host will upgrade and your old scripts won't work.

Magic quotes on might be viewed as a useful safety net for inexperienced programmers. Personally, I think that Magic Quotes are Evil: http://www.webmasterstop.com/tutoria...c-quotes.shtml. It's your call.

Unlike register globals, a script which works with magic_quotes_gpc off won't work perfectly with it on. The "pro" way is to always set magic quotes off - local and live (if you can) - as well as applying the fix (see above link) to distributed programs which might be run in other environments.

Database Managers

You probably got the excellent phpMyadmin with one of the php/mysql/apache packages above. If not see http://www.phpmyadmin.net/. Other db managers worth a look are SQLyog: http://www.webyog.com/ and
Aqua http://www.aquafold.com/index.html

Manuals

You can view the online manual at php.net. There are also downloadable versions for those of us who still don't have broadband. I'd recommend the version with user comments. Essential reading - but note that user comments are not always correct. The ones that aren't will usually be picked up on.

Apache info: http://www.apache.org/

Mysql.com - as with php.net, online and downloadable manuals here.

Of course php works with all kinds of databases, including the more powerful http://www.postgresql.org/ .

Script editors

A proper script editor with syntax highlighting, cliptext, find in files, etc makes life much easier. EditPlus is an inexpensive favourite for many. Htmlkit is free. BBedit for the mac and vim for linux are other popular choices. If your bank balance is up to it, take a look at Zend developer studio.

Php Tutorials

The internet is a fantastic resource for php tutorials. This one from Zend: http://www.zend.com/zend/tut/using-strings.php might be a good place to start.

We have our own PHP Wiki. At the time of writing this has just been launched but should grow into a comprehensive php knowledgebase.

Many good tutorials on these sites:
Zend.com
O'reilly

A variety of internet related tutorials as well as php here: http://www.w3schools.com

And check out the links on php.net.

If all that was too basic try this: http://freebsd.mu/freebsd/archives/000039.html

Database Tutorials

Database design is often neglected but it's the essential foundation of a php web site. Table joins, normal forms: you've got to know it all.
http://www.devshed.com/Server_Side/MySQL
http://www.oreilly.de/catalog/javadt...apter/ch02.pdf

For a general and hands-on excellent SQL-tutorial: http://sqlzoo.net/

Phpcomplete.com http://www.phpcomplete.com has several PostgreSql tutorials.

Coding Styles

Coding styles are a matter of personal preference but it's best to follow common practices as far as possible. One day you might be working in a team or at the very least you're going to be asking for help on the forums. Other people will have to figure out what you're code is doing so a consistent style is a good habit to get into from the start.

Personally I follow most of the PEAR guidelines: http://pear.php.net/manual/en/standards.php

Regex

You may find regular expressions (regex) to be a mind-bendingly frustrating experience. Don't worry: that's normal. Regex'ing was invented by evil madmen for that very purpose.

The good news is that you can often use one of the string functions - eg str_replace(), substr() etc - instead. These are preferred since they are slightly faster. You'll rarely need the extra power of regex.

The posix ereg(), eregi() functions are marginally slower than perl-style preg_match, preg_replace etc and so the latter are preferred.

Syntax is explained in the manual http://www.php.net/manual/en/pcre.pattern.syntax.php

And here's a useful little tool to test expressions: http://www.weitz.de/regex-coach/#install

Php Scripts & Programs

The Evilwalrus script repository http://www.evilwalrus.com/ has many php scripts to download. You can use these in your own programs or read through them to get some ideas.

There are thousands of php programs available for free at hotscripts.com.

One day, when you start mucking about with OOP (object orientated programming), you might want to take a look at another phpdn site: phpclasses.com. Also, phppatterns.com is an excellent source for OOP design.

Help

If you've got a problem the first step is to get the manual out. The manual is your best friend. Love it, cherish it and, above all, read it.

Next try a forum search: there's a wealth of information in here and there's a good chance your problem has been dealt with before.

If that doesn't work, pick the appropriate forum and post a message.

The art of asking good questions: http://www.catb.org/~esr/faqs/smart-questions.html

On our discussion boards, the focus is more on helping people to learn rather than simply handing out working scripts. Someone who is making a real effort to tackle a problem is much more likely to receive help than a "please can anyone give me a file upload script" type of post.

If you post code, don't forget to use the [php] BB code tags: syntax highlighting & proper indentation makes it much easier to read - and so more likely that you'll get a response.

----------

*Please note... parts of this post have come from other sources and have links to the other sources!

*H9 should also make this sticky
Reply With Quote
  #2  
Old 07-01-2008, 10:12 PM
dr2web dr2web is offline
Junior Guru Wannabe
 
Join Date: Jun 2008
Location: maryland
Posts: 80
Default

an easier way to test your scripts before going live is as simple as installing a test domain on the server that you are hosting on. This makes you upload the files after updates but allows for better testing because there will be the same versions will be the same as your live version... I typically use a local setup to get a rough script written, and then put it up on my test domain to fine tune and test. You could easily skip the local if you didnt have it available.
Reply With Quote
  #3  
Old 07-02-2008, 05:39 AM
adsejam adsejam is offline
Junior Guru Wannabe
 
Join Date: May 2008
Location: UK
Posts: 87
Default

Thanks "dr2web"

Some good tips
Reply With Quote
  #4  
Old 07-02-2008, 03:24 PM
dr2web dr2web is offline
Junior Guru Wannabe
 
Join Date: Jun 2008
Location: maryland
Posts: 80
Default

That is why we are all here... right?

I love to offer information if I have soem to share. Afterall it is from forums and online communities that ilearned to script and damn near everything that I know about networking, design, etc... (you get the point)
Reply With Quote
  #5  
Old 07-02-2008, 06:21 PM
danuk danuk is offline
Junior Guru
 
Join Date: May 2007
Location: U.K
Posts: 193
Send a message via MSN to danuk Send a message via Yahoo to danuk
Default

Quote:
Originally Posted by dr2web View Post
That is why we are all here... right?

I love to offer information if I have soem to share. Afterall it is from forums and online communities that ilearned to script and damn near everything that I know about networking, design, etc... (you get the point)
Although he never attended english classes in school ^^^ hehe, just kidding m8.
Reply With Quote
  #6  
Old 07-02-2008, 07:39 PM
adsejam adsejam is offline
Junior Guru Wannabe
 
Join Date: May 2008
Location: UK
Posts: 87
Default

Shame they didn't do humour classes Again, just kidding
Reply With Quote
  #7  
Old 07-02-2008, 11:31 PM
dr2web dr2web is offline
Junior Guru Wannabe
 
Join Date: Jun 2008
Location: maryland
Posts: 80
Default

Quote:
Originally Posted by danuk View Post
Although he never attended english classes in school ^^^ hehe, just kidding m8.
hey dan... writing from cell phone... whats your excuse :P

jk.. all in good humor
Reply With Quote
  #8  
Old 07-03-2008, 12:49 AM
DiverseHosting DiverseHosting is offline
Aspiring Evangelist
 
Join Date: Jan 2008
Location: California
Posts: 364
Send a message via AIM to DiverseHosting Send a message via MSN to DiverseHosting Send a message via Yahoo to DiverseHosting
Default

Quote:
Originally Posted by dr2web View Post
hey dan... writing from cell phone... whats your excuse :P

jk.. all in good humor
I think Dan's excuse is that he is from the UK

Seriously though... The first time I went to the UK, it took me about a week to understand everybody.
Reply With Quote
  #9  
Old 07-03-2008, 04:21 AM
adsejam adsejam is offline
Junior Guru Wannabe
 
Join Date: May 2008
Location: UK
Posts: 87
Default

Quote:
Originally Posted by DiverseHosting View Post
I think Dan's excuse is that he is from the UK

Seriously though... The first time I went to the UK, it took me about a week to understand everybody.
It seriously took you a week to understand everybody ?! Didn't think there was that much of a difference
Reply With Quote
  #10  
Old 07-03-2008, 05:07 AM
DiverseHosting DiverseHosting is offline
Aspiring Evangelist
 
Join Date: Jan 2008
Location: California
Posts: 364
Send a message via AIM to DiverseHosting Send a message via MSN to DiverseHosting Send a message via Yahoo to DiverseHosting
Default

Quote:
Originally Posted by adsejam View Post
It seriously took you a week to understand everybody ?! Didn't think there was that much of a difference
lol... That's what I thought too. I've seen movies and shows, etc. with people of varying accents, and even met tourists in the US, so I didn't think it was that big of a difference. Not to mention that I didn't put much thought into it since I speak English, and they speak English. I was shocked to learn what a difference there actually is.

Take India, for example: India is an English-speaking country, but I constantly hear others complain that they can't understand anything someone from India says. It is the same principal between the US and the UK, or Australia (btw: If you are ever in Australia, be careful when ordering a beer... Their beers are quite a bit larger than the beers in the US, and alot stronger as well!). Even within the US, there is a huge difference between Wisconsin, and Texas, for example.

Accents are only half the battle. I couldn't believe the subtle differences in the vocabulary either. Just a few words that come to mind are lorry, barney, chips (not the same as US), dummy (I had young family with me my first time), etc. It's almost like learning a completely new language.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Are you a topic starter or a responder? subho General 4 02-06-2009 12:04 AM
google pack STARGAZER Web Development 0 12-28-2007 03:38 AM
Let us server you...A pack of problems is what im guessing. jcws649 Customer Testimonials 2 08-03-2007 12:20 PM


All times are GMT -5. The time now is 03:04 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

Host Nine

Our mission began in 2006. Thousands of awesome clients later, we are now one of the most popular hosters in the world.
Most of this is because of our fantastic support. Join us, you'll be glad you did - that's a given.