The following workshop includes questions you might ask about server-side development, quizzes to test your knowledge, and two quick exercises.
At work, all of our applications are written using Active Server Pages. Why didn't you write about that?
There are a number of popular platforms for writing web applications. PHP has the advantage of running on a number of operating systems, including Windows, Mac OS X, and Linux. Furthermore, support for PHP is offered by many web hosting providers. Finally, as you'll learn in the next lesson, there are many applications already written in PHP that you can take advantage of. Knowledge of PHP can be helpful in working with them.
Do I need a special application to edit PHP files?
Just as with HTML, PHP files are normal text documents. Some text editors have specialized features that make working with PHP easier, just as there are for HTML. If you're just starting out, using Notepad or any other regular text editor will work fine, but you'll probably want to find a more powerful tool for writing PHP if you find yourself programming in PHP a lot.
How do I deploy PHP files to a server?
There are no special requirements for deploying PHP files. You can just transfer them to the server as you would regular HTML files. As long as the server is configured to handle PHP, you should be fine. The one thing you do need to be careful to do is to make sure your directory structure is the same on the server and on your local computer. If you are using includes and directory paths change, your includes will break.
Are PHP scripts browser-dependent in any way?
What is the difference between double and single quotes in PHP?
How do the include_once and require_once functions differ?
Which functions can be used to help avoid cross-site scripting attacks?
How do you declare an associative array in PHP?
In PHP, strings in double quotes are parsed for variable references and special characters before they are presented. Strings in single quotes are presented as is.
The include_once function does not return a fatal error if the file being included is not found. With require_once, if the file is not found, a fatal error occurs and the rest of the page is not processed.
You can use htmlspecialchars() to escape the characters used to generate HTML tags for a page. You can use strip_tags() to remove any HTML tags from a string. Either approach should prevent users from using malicious input to attempt a cross-site scripting attack.
Associative arrays are declared as follows:
$array = ('key' => 'value, 'key2' => 'value2');
Get PHP up and running on your own computer.
Write a script that enables a user to show the current date and time on a web page.
Go to the PHP manual online and find a built-in function that wasn't introduced in this lesson. Use it in a script of your own.