Learning PHP for beginners step by step. Using the exercise files. Download them from the course page and save them in a convenient place on your local computer. I’ve got them here on my desktop.
So let’s just take a look at them. All the Exercise Files are organized in folders numbered after each chapter. And inside are subfolders for the individual videos that require Exercise Files. When a file is in a different state at the end of the video, _end is appended to the file name.
If the video starts with a blank file, only the version with _end is provided. And in some cases, let’s just take a look at Chapter Nine, where a lot of files change during the course of the video, there are two separate folders: begin and end.
This is what the files look like at the beginning of the video and this is what you should end up with at the end. PHP files need to processed by a web server. So you need to copy all of the Exercise Files to your testing server root.
The location of your server or document root depends on your testing environment. In MAMP on Mac OS X, it’s at /Applications/MAMP/htdocs. If you’re using the built-in version of Apache on Mac OS X, it’s at /Library/WebServer/Documents. In WampServer, it’s on your C:\wamp\www. And in XAMPP on Windows, it’s on C:\xampp\htdocs.
If you’re using your remote server for testing or when you eventually want to show off your new skills, the name of the document root can vary. On many sites, it’s htdocs. public_html is also common as is www. To use the Exercise Files, copy the Exercise Files folder and all of its contents to your server document root folder. Rename the folder to introducingphp as one word and all in lowercase.
File and folder names in a website become part of the URL, so they should never contain spaces. It’s also a good idea to use all lowercase because most PHP servers are case-sensitive. If you set up the Exercise Files like this in a local testing environment the URL for every file will be http://localhost/introducingphp/ http://localhost/introducingphp/ followed by the folder names and file name.
After you’ve copied the files and renamed the folder, make sure that your testing server is running and type the following URL in a browser address box: http://localhost/introducingphp/introduction/test.php http://localhost/introducingphp/introduction/test.php And if everything is working correctly you should see the following message. This day of the week here is generated dynamically by PHP.
So it will differ depending on when you test this page. If the day of the week is out by one, it means you need to fix the time zone on your server. We’ll deal with that later in the course. And if this page is working you’re ready to continue with the course. If you couldn’t display the test page, check the following: Is the web server in your testing environment running? In most cases, this will be Apache. Can you view other PHP files on localhost? If you can’t, you need to fix your installation of Apache and PHP first.
But if you can view other PHP files, did you copy the Exercise Files folder to the server root? Did you rename the folder to introducingphp as all one word? And did you spell the URL correctly? Mistakes in file and folder names are a common cause of problems. Hopefully, that checklist will get you up and running.