I wanna start with first program in PHP. I have got installed xampp and had a look at sample codes. How to start writing my own code to build web pages. Where to start with. Do i have to write a text file as code and open it in explorer like we did it in HTML.Thanks in advance.
You can use almost any text editor you like, but one with syntax highlighting makes things easier. Notepad++ is a handy little editor for Windows, and has syntax highlighting for many different languages, including PHP, HTML, CSS and SQL.
Have a look at some tutorials - it's often easier than wading your way through the docs - although the docs are, of course, essential.
There's a good step-by-step beginners guide on tizag.com:
PHP Tutorial - Learn PHP
Once you've mastered the basics, there are plenty more tutorials available. I quite like some of the tutorials on PHPro, but there are many others. Here's a few PHPro articles to get you started:
Object Oriented Programming with PHP
Introduction to PHP Sessions
Introduction to PHP and MySQL
Introduction to SimpleXML with PHP
Parse HTML with PHP and DOM
Introduction to PHP Regex
Note: I put the regex tutorial after the SimpleXML tutorial for good reason. If you ever get the urge to parse HTML with regular expressions, just read this. If you are still not sure, read it again. :-)
When you get to database stuff (I'm assuming MySQL for the sake of simplicity, but this applies equally to other DBMSs), warm yourself up with a little dynamic SQL and mysql_real_escape_string. Then swiftly move on to mysqli::prepare prepared statements. You will probably save yourself a whole lot of problems if you treat dynamic SQL as a learning exercise, but then move onto prepared statements for everything else.
Try to become familiar with some of the common PHP security problems, and what can be done to mitigate them.
It's a good idea to develop consistent naming standards.
When you start writing more complex sites, you may want to look into template engines. There's a degree of disagreement about these, as PHP can be used directly as a template system. However, I've had good experiences with Smarty, and find that it helps me to keep the application logic separate from the display code.
Templating brings me onto frameworks. They take a lot of the grunt work out of writing web sites. There are many available, and everyone will have their own opinion about which is best. So instead of suggesting one, here's a link to a list of popular ones:
http://www.phpframeworks.com/
By the time you get to this stage, you'll probably find the use of debugger very handy. A good starting point (it works, and it's free), is a combination of Eclipse with XDebug - but there are other choices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With