Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Configuring PHP


PHP with MySQL Essential Training

with Kevin Skoglund

Video: Configuring PHP

In this movie, we're going to learn how to configure PHP. Specifically, there are three things that we're going to be looking for. And that's to configure the error reporting, the output buffering, and the default timezone. Let's see how to do those. So in the last movie, we saw how to use the phpinfo function in order to bring up the phpinfo information page. This shows all of our configuration. It's a great place to look and see how things are set at the moment. The most important part, though, are these lines right here. Configuration file for php.ini. That is where our configuration is going to be loaded. Loaded configuration file.
Expand all | Collapse all
  1. 4m 8s
    1. Welcome
      1m 0s
    2. Using the exercise files
      3m 8s
  2. 15m 6s
    1. What is PHP?
      3m 52s
    2. The history of PHP
      2m 51s
    3. Why choose PHP?
      4m 10s
    4. Installation overview
      4m 13s
  3. 1h 3m
    1. Overview
      2m 33s
    2. Working with Apache Web Server
      6m 56s
    3. Changing the document root
      7m 24s
    4. Installing to Yosemite
      8m 13s
    5. Enabling PHP
      6m 16s
    6. Upgrading PHP
      3m 30s
    7. Configuring PHP
      10m 3s
    8. Installing MySQL
      5m 46s
    9. Configuring MySQL
      7m 24s
    10. Text editor
      5m 1s
  4. 31m 25s
    1. Overview
      3m 27s
    2. Installing WampServer
      5m 46s
    3. Finding the document root
      2m 24s
    4. Configuring PHP
      8m 12s
    5. Configuring MySQL
      5m 45s
    6. Text editor
      5m 51s
  5. 19m 12s
    1. Embedding PHP code on a page
      6m 43s
    2. Outputting dynamic text
      5m 55s
    3. The operational trail
      2m 27s
    4. Inserting code comments
      4m 7s
  6. 1h 18m
    1. Variables
      7m 50s
    2. Strings
      4m 38s
    3. String functions
      8m 54s
    4. Numbers part one: Integers
      6m 27s
    5. Numbers part two: Floating points
      5m 25s
    6. Arrays
      10m 0s
    7. Associative arrays
      6m 37s
    8. Array functions
      6m 33s
    9. Booleans
      3m 50s
    10. NULL and empty
      5m 15s
    11. Type juggling and casting
      8m 27s
    12. Constants
      4m 43s
  7. 27m 37s
    1. If statements
      6m 0s
    2. Else and elseif statements
      4m 16s
    3. Logical operators
      7m 30s
    4. Switch statements
      9m 51s
  8. 42m 15s
    1. While loops
      8m 41s
    2. For loops
      5m 59s
    3. Foreach loops
      8m 16s
    4. Continue
      8m 28s
    5. Break
      4m 8s
    6. Understanding array pointers
      6m 43s
  9. 37m 25s
    1. Defining functions
      8m 25s
    2. Function arguments
      5m 32s
    3. Returning values from a function
      7m 33s
    4. Multiple return values
      4m 53s
    5. Scope and global variables
      6m 2s
    6. Setting default argument values
      5m 0s
  10. 20m 18s
    1. Common problems
      3m 47s
    2. Warnings and errors
      8m 36s
    3. Debugging and troubleshooting
      7m 55s
  11. 57m 57s
    1. Links and URLs
      5m 33s
    2. Using GET values
      5m 35s
    3. Encoding GET values
      8m 41s
    4. Encoding for HTML
      9m 26s
    5. Including and requiring files
      7m 40s
    6. Modifying headers
      6m 45s
    7. Page redirection
      6m 43s
    8. Output buffering
      7m 34s
  12. 1h 3m
    1. Building forms
      7m 28s
    2. Detecting form submissions
      5m 59s
    3. Single-page form processing
      7m 57s
    4. Validating form values
      10m 40s
    5. Problems with validation logic
      9m 54s
    6. Displaying validation errors
      7m 23s
    7. Custom validation functions
      6m 28s
    8. Single-page form with validations
      7m 25s
  13. 28m 5s
    1. Working with cookies
      2m 49s
    2. Setting cookie values
      5m 55s
    3. Reading cookie values
      6m 1s
    4. Unsetting cookie values
      4m 51s
    5. Working with sessions
      8m 29s
  14. 48m 39s
    1. MySQL introduction
      6m 43s
    2. Creating a database
      7m 41s
    3. Creating a database table
      7m 42s
    4. CRUD in MySQL
      5m 48s
    5. Populating a MySQL database
      7m 32s
    6. Relational database tables
      6m 40s
    7. Populating the relational table
      6m 33s
  15. 56m 4s
    1. Database APIs in PHP
      4m 51s
    2. Connecting to MySQL with PHP
      7m 45s
    3. Retrieving data from MySQL
      8m 47s
    4. Working with retrieved data
      6m 12s
    5. Creating records with PHP
      6m 58s
    6. Updating and deleting records with PHP
      9m 6s
    7. SQL injection
      3m 5s
    8. Escaping strings for MySQL
      6m 45s
    9. Introducing prepared statements
      2m 35s
  16. 35m 58s
    1. Blueprinting the application
      7m 19s
    2. Building the CMS database
      5m 14s
    3. Establishing your work area
      4m 38s
    4. Creating and styling the first page
      4m 22s
    5. Making page assets reusable
      6m 36s
    6. Connecting the application to the database
      7m 49s
  17. 32m 49s
    1. Adding pages to the navigation subjects
      5m 58s
    2. Refactoring the navigation
      6m 7s
    3. Selecting pages from the navigation
      6m 2s
    4. Highlighting the current page
      5m 26s
    5. Moving the navigation to a function
      9m 16s
  18. 1h 45m
    1. Finding a subject in the database
      9m 48s
    2. Refactoring the page selection
      10m 52s
    3. Creating a new subject form
      6m 55s
    4. Processing form values and adding subjects
      11m 20s
    5. Passing data in the session
      9m 16s
    6. Validating form values
      9m 40s
    7. Creating an edit subject form
      8m 30s
    8. Using single-page submission
      7m 44s
    9. Deleting a subject
      9m 44s
    10. Cleaning up
      10m 37s
    11. Assignment: Pages CRUD
      4m 30s
    12. Assignment results: Pages CRUD
      6m 10s
  19. 39m 26s
    1. The public appearance
      8m 52s
    2. Using a context for conditional code
      11m 37s
    3. Adding a default subject behavior
      6m 9s
    4. The public content area
      5m 51s
    5. Protecting page visibility
      6m 57s
  20. 1h 3m
    1. User authentication overview
      4m 3s
    2. Admin CRUD
      8m 41s
    3. Encrypting passwords
      7m 26s
    4. Salting passwords
      5m 42s
    5. Adding password encryption to CMS
      11m 54s
    6. New PHP password functions
      3m 13s
    7. Creating a login system
      11m 28s
    8. Checking for authorization
      5m 48s
    9. Creating a logout page
      5m 40s
  21. 2m 4s
    1. Next steps
      2m 4s

please wait ...
PHP with MySQL Essential Training from
14h 24m Beginner Jun 04, 2013 Updated May 20, 2015

Viewers: in countries Watching now:

PHP is a popular, reliable programming language at the foundation of many smart, data-driven websites. This comprehensive course from Kevin Skoglund helps developers learn the basics of PHP (including variables, logical expressions, loops, and functions), understand how to connect PHP to a MySQL database, and gain experience developing a complete web application with site navigation, form validation, and a password-protected admin area. Kevin also covers the basic CRUD routines for updating a database, debugging techniques, and usable user interfaces. Along the way, he provides practical advice, offers examples of best practices, and demonstrates refactoring techniques to improve existing code.

Topics include:
  • What is PHP?
  • Installing and configuring PHP and MySQL
  • Exploring data types
  • Controlling code with logical expressions and loops
  • Using PHP's built-in functions
  • Writing custom functions
  • Building dynamic webpages
  • Working with forms and form data
  • Using cookies and sessions to store data
  • Connecting to MySQL with PHP
  • Creating and editing database records
  • Building a content management system
  • Adding user authentication
Kevin Skoglund

Configuring PHP

In this movie, we're going to learn how to configure PHP. Specifically, there are three things that we're going to be looking for. And that's to configure the error reporting, the output buffering, and the default timezone. Let's see how to do those. So in the last movie, we saw how to use the phpinfo function in order to bring up the phpinfo information page. This shows all of our configuration. It's a great place to look and see how things are set at the moment. The most important part, though, are these lines right here. Configuration file for php.ini. That is where our configuration is going to be loaded. Loaded configuration file.

It's going to be inside usr/local/php5/lib. And the file itself is called php.ini for initialize. That's what the ini stands for. That's the file. The php.ini file is going to hold all of the configuration. It's all of the things that we see on this page. There's one other important thing that I want you to notice as well, which is the line below it, scan this directory for additional ini files. Now, this is not always the case with all PHP installations. But the one that we've downloaded, the one that I used from Liip, well, that is going to use that. It was created so that it will look in this php.d directory for additional ini files.

And that's going to be important. We want to remember that. So we actually have configuration stored in two places. And our main ini file and in these extra files that are inside this other directory. So let's start by just copying this path all the way to the ini file. Use Cmd+C see to do that. Switch back to my command line and I'll use nano to edit that file. So here it is. Here's my configuration. You can scroll through it and you can see all the different things that you can configure in PHP. But let's jump straight to the things that we're looking for.

I'm looking for display errors, first of all. So I'm going to use Ctrl+W to search and it'll ask me what I want to search for. Display_errors. That comes up with first a quick reference and basic settings. I don't want that so lets hit Ctrl+W again. I don't have to type it again. The default is to search for display errors again. I hit Return, and here it is. This is the real value. How do I know it's the real value? Because it doesn't have a semicolon in front of it. The semi colon's letting us know that these lines are comments.

Ones that don't have semicolons are the real active lines, the actual configurations going on. You can see that it actually gives me some helpful information. It tells me what the default value is, the development value, production value that you'd want to have. Now, for in development, we want to see our errors. We want to know what went wrong so we can fix it, we want as much information as possible. But when we actually deploy it to the real world, we are not going to want to give all sorts of server information to people so we are going to turn off the errors in that case. But you want to make sure that right now, display errors is on. The next one that I want us to check for is error reporting. So, Ctrl+W again, its time to search for error reporting. And let's do Ctrl+W again, a couple of times to get to this one. Error reporting is set to E_ALL.

This is a constant value. And this constant value actually represents a number. So if you look over here in the config file into the search for error reporting, you will see error reporting right here is 32767. That's what this value represents, right? So E_ALL gets translated into a number when it gets stored. It's a lot easier for us to work with it, though, being this constant, E_ALL. So this will report back all errors to us.

Now, before version 5.4 of PHP, if you wanted all errors, you also had to put the upright pipe, followed by E_STRICT. The strict errors were a separate category that were not included in all, and that's counter intuitive. All should include everything, right? So they did make that change, and strict got incorporated into all so it includes that as well. If you don't want something in there, like you don't want these strict ones. Well then, you use the & and then the curly squiggle followed by E_STRICT.

So that means all errors except for the STRICT errors. You can do the same thing for all the different kind of errors that there are. Notices, deprecations that's code that's going to be going away soon. And you can see that they tell you, when you're in production, it's good idea to not have it raise errors on depracated code strict usage of things. But when we're in development, go ahead and give us a warning about those kinds of usages. So you want to make sure that you have E_ALL or that you have E_ALL followed by E_STRICT if you happen to have an older version, that works as well. Okay, so now we have that.

The last one I want to check for on errors is HTML errors. So we'll do our search again, this time for html_errors, we want to make sure that this is turned on. This says that when we do see errors, let's give them to us in HTML format. Just looks a little nicer, and actually has some links that we can click on. So now we've got our errors set to show us all errors. Let's now take a look at output buffering. So Ctrl+W and let's look for output_buffering. Here's the actual directive. Now, this has a value of 4096, that's how much data it will buffer before it outputs.

We'll talk more about output buffering later. For now, turn it off. Now, when I'm developing, I often have it on. But I want us to have it off so that you can see what happens when it's off. It's going to be very instructive to understand this part of PHP. So let's turn it off then we'll talk about what it does, and why we would want it. And then we can go and turn it back on, and we'll be able to use output buffering as a feature because we'll be knowledgeable about it at that point. So to start with, we're going to turn it off. And then the last one we're going to do is the timezone.

So let's go Ctrl+W again, let's search for timezone, and here's the one we want. It is commented out. We're going to take away the semicolon at the beginning and then we're going to put inside quotes, our timezone. What timezone do we want to be using? Now, there's a very specific format that these timezones need to be in. And you can actually just do a search for php timezones and you'll find it, or So this is a list of all the supported timezones.

I'm in America so I'm going to click that one. And here you see a list of all the American timezones. This is both North and South America... You can see some American cities that might be close to you. So there's Detroit and there's another one here for Los Angeles. I'm going to be close to New York, that's my time zone, so I'm going to putting in America/New_York. I'll just go ahead and copy that, Cmd+C. I'll switch back over here and inside those quotes, then I'll paste that in. So it's going to set my timezone to be America/New_York.

Now, you could also set other information, latitude, longitude, things like that. But those aren't important to us at this point. We just need to make sure we have the timezone set. And the reason why we want to take time to do this is because PHP now includes some warnings that will pop up while we're developing. It'll say hey, you're working with date. And you don't have a default timezone set. That's not very advisable. In order to avoid those warnings, we're going to go ahead and set a default timezone for ourselves now. It's also a good practice to be in. So let's save that. Save modified buffer? We want to say yes, and then hit Return to keep it in that file name. We need to restart Apache.

For our changes to take effect. It wants our password. That's our password we used to install software on our Mac. And then let's switch back to our phpinfo file. And let's go up to the very top and we'll reload the page. So now let's look for output_buffering, no value. So it turned off output_buffering for us. Where before it said 4096 there. Let's take a look at time zone. Now, wait a minute. This isn't the time zone that I put in. And here's another one down here. This isn't the time zone I put in. So what happened? Remember that i told you there are additional config files.

If you go look in this directory, user local php 5, slash, php.d -- copy that Let's just go into that directory using cd. Then if we take a look at what's in that directory, you'll see that there are more ini files. And the one that really matters is this one right here. That's the ini file that contains a timezone setting that going to cause us problems. So let's just edit that real quick. Nano And we'll open up that file, and here it is. You can see that it has set Europe Zurich as being the the time zone. We can just comment that out.

And our default one will take place. I'll comment it out there, latitude and longitude as well. Or, we could change it here. We could change that value to be the same time zone that we had in the other place. All the other settings that they've got here are fine, they're not offensive. Notice that they did set error reporting here. If we wanted ours to take effect, then you could go ahead and then take that out as well. Alright, so once we've done that, let's do the Ctrl+X, save our modified buffer, and we'll save that file once again. We need to restart Apache. I'm going to use my up arrow a couple of times to get back to the command and hit Return.

Now, that Apache's restarted, we'll come back here and reload our ini page, and let's search for time zone again. And here it is. America/New York. So it worked. It did set it to the correct value. Now we have the basic configuration that we need to start developing with PHP. And not only that, we have a little bit of an understanding of how we go about configuring PHP. That we make changes to that php.ini file, we restart Apache, and then we can come here and check those values to make sure they're correct. There are other things in that file you can change. There's maximum execution time, there request to auto run, there's the maximum file size that will be uploaded. There's where you want to store your error logs. There's all sorts of things in there that you can go through and customize and make PHP work exactly the way that you want.

But this is enough to get you started, so let's move on and get MySQL installed.

Find answers to the most frequently asked questions about PHP with MySQL Essential Training .

Expand all | Collapse all
please wait ...
Q: This course was revised on 6/4/2013. What changed?
A: The old version of this course was 6 years old and it was time for a complete revision, using PHP 5.4. (The tutorials will work with any version of PHP and covers any differences you might encounter). The author has also added updated installation instructions for Mac OS X Mountain Lion and Windows 8. The topics and end project are the same, but the code is slightly different. It also addresses frequently asked questions from the previous version.
Q: This course was updated on 5/20/2015. What changed?
A: We added one movie called "Changing the document root in Yosemite," which helps the Mac installation run more smoothly.
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed PHP with MySQL Essential Training.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts. provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now

A trusted source for knowledge.


We provide training to more than 4 million people, and our members tell us that helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.