Before you continue you should have a basic understanding of the following:
HTML / XHTML
Some scripting knowledge
If you want to study these subjects first, find the tutorials on our Home page.
What is PHP?
PHP stands for PHP: Hypertext Preprocessor
PHP is a server-side scripting language, like ASP
PHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
PHP is an open source software (OSS)
PHP is free to download and use
What is a PHP File?
PHP files may contain text, HTML tags and scripts
PHP files are returned to the browser as plain HTML
PHP files have a file extension of ".php", ".php3", or ".phtml"
What is MySQL?
MySQL is a small database server
MySQL is ideal for small and medium applications
MySQL supports standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
PHP + MySQL
PHP combined with MySQL are cross-platform (means that you can develop in Windows and serve on a Unix platform)
Why PHP?
PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)
PHP is FREE to download from the official PHP resource: http://www.php.net/
PHP is easy to learn and runs efficiently on the server side
Where to Start?
Install an Apache server on a Windows or Linux machine
Install PHP on a Windows or Linux machine
Install MySQL on a Windows or Linux machine
Various PHP Programming Tricks
I'll be presenting a couple of nice PHP Programming Tricks in this page. You can take a look at the various tricks in these sub pages.
Force a secure HTTP connectionif (!($HTTPS == "on")) { header ("Location: https://$SERVER_NAME$php_SELF"); exit; }
Get the date$today = getdate(); $month = $today['month']; $mday = $today['mday']; $year = $today['year'];
Random LoadingYou can load random stuff by using this code. For this example, I load random color code:$selectnumber = rand (1, 5);if($selectnumber==1) $pagebg="#990000";if($selectnumber==2) $pagebg="#0000FF";if($selectnumber==3) $pagebg="#00AAAA";if($selectnumber==4) $pagebg="#000099";if($selectnumber==5) $pagebg="#DDDD00";
Easy Way to List Directory Structure$path = "/home/user/public/foldername/";$dir_handle = @opendir($path) or die("Unable to open $path");
while ($file = readdir($dir_handle)) { if($file == "." $file == ".." $file == "index.php" ) continue; echo "$file
"; }closedir($dir_handle);
Easy Way to Optimize Database TabledbConnect()$alltables = mysql_query("SHOW TABLES");
while ($table = mysql_fetch_assoc($alltables)){ foreach ($table as $db => $tablename) { mysql_query("OPTIMIZE TABLE '".$tablename."'") or die(mysql_error()); }}
Create a password protect webpage
Login
This is the protected page. Your private content goes here.
MySQL related tools:MySQL Administrator - a graphical user interface (GUI) tool to administer MySQL databases. Mainly geared towards DBAs, but very useful for your local development tasks as well. MySQL Query Browser - a GUI tool to query MySQL databases. Also very useful to write/debug stored procedures and functions on MySQL 5. DBDesigner - a GUI tool to help you design a database visually. Allows you to synchronize changes from your design document back into the MySQL database, and also allows you to reverse engineer a database into a design document. PHP related tools:PEAR - the analogous of CPAN of Perl for the PHP community, this is a set of high quality PHP components (basically classes) ready to be re-used and integrated into your application. Pretty much everything you might need to build a web application is available here. Zend Studo IDE - one of the best text editors aimed at PHP developers, this is a must for big projects. It really does make development a lot easier. Price starts at $99 for the standard package. Zend Encoder - another pretty interesting tool from Zend allows you to encode your PHP source code, and ship that to your customers. That gives you the peace of mind of not having to worry about customers having access to your proprietary code. PHPEclipse - a free plugin to the popular Eclipse IDE that brings a bunch of advanced features (similar to what you would find in Zend Studio) to PHP developers. Xdebug - a PHP extension that provides a lot of debugging and profiling related information. JavaScript related libraries:moo.fx - a lightweight (3kb) JavaScript effects library. See the website for more details and a demonstration of what it can do. This is very useful for Web 2.0 applications, as you can hide/display certain parts of your app. Tooltip.js - a JavaScript library aimed at creating tooltips powered by AJAX. Pretty simple stuff, but also very useful for those cases where you need this type of functionality. Web Development tools (mainly Firefox extensions):Webdrive - a special Windows-only tool that allows you to mount a drive to a FTP/SFTP/SSH server. Commercial application, but very useful. Web Developer extension - provides a ton of useful tools and information to a web developer. Colorzilla extension - allows you to quickly get the color information from a web page. Live HTTP Headers extension - allows you to monitor the HTTP requests that are generated from a web application
PHP Help
It's not hard to pick up the basics of any web "language" or programming language quickly, but to really understand and master it takes time, effort, and lots of practice. Try these:
PHP: A simple tutorial - Manual
Here we would like to show the very basics of PHP in a short, simple tutorial. This text only deals with dynamic webpage creation with PHP, though PHP is ...http://www.php.net/tut.php -PHP TutorialFree HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building.http://www.w3schools.com/php/default.asp
MySQL AB :: MySQL 5.0 Reference Manual ::
This chapter provides a tutorial introduction to MySQL by showing how to use the mysql client program to create and use a simple database. mysql (sometimes ...http://dev.mysql.com/doc/refman/5.0/en/tutorial.html
MySQL AB :: Building a Database-Driven Web Site Using PHP and MySQLBuilding a Database-Driven Web Site Using PHP and MySQL by Kevin Yank.http://dev.mysql.com/tech-resources/...dws/index.html
MySQL Help, MySQL Tutorials, MySQL Programming, MySQL TricksA collection of MySQL tutorials on Administration, and Grant Tables. Includes a "Beginning MySQL" tutorial.http://www.devshed.com/c/b/MySQL/
PHP/MySQL Tutorial - Part 1Learn how to use PHP to interact with the free MySQL to make fully dynamic and database-driven sites. (Free Webmaster Help)http://www.freewebmasterhelp.com/tutorials/phpmysql
TAASC: MySQL Basics -- A Helpful MySQL TutorialTips for installing MySQL on Windows machines. Also provides step by step instructions on creating and maintaining MySQL databases using basic SQL commands.http://www.analysisandsolutions.com/code/mybasic.htm
PHP MySQL TutorialSimple PHP and MySQL tutorial with examples like creating a guestbook, uploading image to database and creating simple content management system (CMS).http://www.php-mysql-tutorial.com/
MySQL Tutorial - IntroductionAn introduction to using the MySQL database. This tutorial uses PHP to complete many basic MySQL tasks.http://www.tizag.com/mysqlTutorial/
PHP/MySQL TutorialWebmonkey's 3-lesson tutorial explains how to create data-driven sites using MySQL and PHP.http://www.webmonkey.com/webmonkey/p...tutorial4.html
MySQL & PHP TutorialThe Vermont Web Wizard's tutorial on connecting to MySQL using PHP as the Web front end.http://www.vtwebwizard.com/tutorials/mysql/