PHP Front To Back
Lesson 1 of 22 · PHP Front To Back [Part 1] - Series Introduction · IT & Software
About this course
you guys looking to the PHP front-to-back series now initially this was going to be a crash course in one video but I find that crash courses
limit what I can show you because I don’t like making them longer than 45 minutes to an hour and my goal for this series is to teach you an entire language not just get your feet wet but
teach you start to finish or rather front to back now like with any technology that I choose to do videos on some of you are going to be saying damn it I hate PHP but I would still
encourage you to watch the series and learn it because whether you like it or not PHP is all over the place and you don’t have to like it to learn it all right now a little while ago I realized
that my channel has so much JavaScript and so many frameworks and very little PHP and I actually know more about PHP than I do JavaScript all right so once this series is over we’ll do another
language okay so whether it’s Python or Java or anything else basically I want to have a channel that anyone can go to to learn anything when it comes to programming
all right so that’s my little spiel now let’s take a look at what’s included in this series now this is just what I came up with in a few minutes they’ll be adding things as you move along but
we’re going to start with talking about what PHP is and why you would use it and we’ll try to get that out of the way in this video then I’m going to show you how to get PHP set up on your machine
now PHP needs a server to run so we’re going to be installing a software suite called xampp or also pronounced amp which will give us an Apache server PHP MySQL and a tool called PHP myadmin to
manage databases okay i’m using xampp because it’s cross-platform now I’m using Windows but it’s also available for Linux and Mac okay and you don’t have to use that there’s a lot of other
tools you can use or you can just set up a lamp stack in fact it doesn’t matter what environment you’re working in for this series the code is all the same alright so we’ll also look at the basic
code syntax such as variables arrays loops conditionals etc I’ll try to combine a couple of those into single videos so that we don’t have an entire video on just variable
all right even though I do want to really get into the syntax so PHP is very flexible which can be a good thing or a bad thing but I’ll be showing you how to use
procedural programming as well as object-oriented programming and how to create classes and so on all right we’ll also create dynamic web pages and we’ll look at includes and how how to write
code without repeating yourself we’ll look at form submission and superglobals how to make and receive get requests and post requests we’ll also be working with databases almost mostly at MySQL but
I’ll also show you how to use post grabs and maybe even something like MongoDB alright and then once you learn all the basics we’ll go ahead and create some mini projects such as a contact form a
user login system and then maybe at the very end we can do a big project alright so now that we know what’s going to be in a series let’s talk a little bit about what PHP is and some of its basic
principles so PHP has stood for a couple different things throughout the years it now stands for PHP hypertext preprocessor so it is a recursive acronym it was created back in 1995 by a
guy named Rasmus lured off ok PHP is an open-source server-side programming language or scripting language so all PHP is hosted on a server and it’s not like Java Script that can be
run on the user’s client machine it needs to need the server to run ok and Apache is the most popular type of server that PHP runs on but you can use other things as well
Pachi is part of the lamp stack which is Linux Apache MySQL and PHP and that’s an extremely popular stack to work with all right let’s see so PHP can be directly embedded into HTML markup this is one of
the huge advantages of PHP we need to use PHP tags when we do that which we’ll talk about later and then in order for PHP to run the file has to have a dot PHP file extension so even if your HTML
file is on the server it won’t process the PHP unless it has the right file extension all right so let’s take a quick look at how PHP works okay so if you look at this image over
here on the right it starts with a user on a client machine making a page request usually to a PHP file then the server process is that request and uses a PHP interpreter ok PHP also has a
bunch of extensions some are enabled by default and you can add and remove extensions and then if you know enough you can even create your own now while PHP is being processed it has
the ability to work with a database that’s one of HP’s best features is that you can use it with almost any type database MySQL is probably the most popular one for at least for small and
medium-sized applications it can also interact with other files on the system you can read from other files as well as write to them ok once the processing and the interpreting is complete it’ll send
the results to the client or the browser now it’s important to understand that the actual PHP script and the PHP programming isn’t sent to the browser it doesn’t work like it does if you were
just requesting an HTML page it sends the result of the script ok and this is usually HTML but PHP can also send plain text Jason XML PDFs etc alright but it
usually just sends the HTML result if you were to view your source code in your browser you’ll see the HTML you’ll see the client-side JavaScript you’ll see the CSS but you won’t see the PHP
alright so most developers either love or hate PHP I just did a video called should you learn PHP pros and cons so I’m not going to dive deep into the advantages and disadvantages you can
check that video out if you want and learn a little bit more about that but some advantages are that it’s very easy to learn when you compare it to other server-side languages it’s not tight you
don’t have to define your data types and so on it’s free and completely open-source there’s a ton of support on the Internet there’s really good documentation and so
many people know it no PHP bad you can always find help when you need it alright it’s also completely cross-platform like I said it can run on Windows Linux Mac and usually runs on an
Apache server but can use other types of servers as well okay PHP also gives you a lot of freedom which I said could be either good thing or a bad thing but it allows you to be
unique and original but at the same time it allows people to write horrible code okay because there’s less structure and less strict PHP also has a ton of frameworks some are great some are not
laravel is probably the most popular right now I also like symphony and code ignitor which is really easy to learn and then PHP is also very compatible with almost any type of database okay
MySQL PostgreSQL and even no SQL databases like MongoDB so you can do a lot of stuff with PHP it can pretty much do anything that any other server-side language can do it can create dynamic
page content interact with other files on the server and files of all different types it can also collect information from web forms and process them it can send and receive cookies to and from the
browser it can also use sessions which we’ll talk about later it can create read update and delete data from a database and it can implement access control on your website it can encrypt
data and just about anything else all right so here’s a couple of types of websites and applications that are usually created with PHP so basic websites like a business site or
something like that blog type websites where your content is stored in the database and pages are created dynamically shopping cards or e-commerce sites social networks where people can
register and login you can easily encrypt passwords content management systems in fact PHP is used with all of them the most popular CMS applications such as wordpress joomla drupal and
there’s a bunch of others as well all right you can make membership websites with access can trol you can build search engine engines and make complex full-text search
queries and you can also build back-end API including restful JSON api’s alright so I don’t want to take any more time up with these slides now we’re going to jump in and we’re going to set up PHP
and we’ll start to code