In this Articles, we’re going to code up our very first PHP script and to start out with the basics.


the very first thing you will need is a closing and opening tag so all of your PHP code will go between the opening tag which is right here and the closing tag so the opening tag starts out with an angle bracket then a question mark and then PHP and then it’s closed out with a question mark and an angle bracket so if you mess this up .

somehow your PHP code will not get executed so you need to have exactly this format so once again everything that goes on between these two tags will be PHP code and then once you go past this closing tag you’re back to HTML but it once again everything between these two tags is PHP so let’s go ahead and 

save this first before we actually put some code in there so we’ll do a save as and you want to select PHP in all these different file formats and it’s down here so that’s what we want now we’re going to browse to our htdocs folder wherever you installed it and I installed it on my C Drive and again we’re going to put it in HT Docs and you can name this whatever you want I’m just going to call this lesson now you’ll notice after I 

hit the Save button this color up here will change it kind of indicates hey you’re really good to go now with PHP see how that changed okay so we’re going to use the echo function it’s actually not truly a function because you don’t actually have to use parentheses but it acts like one so we write in echo and all echo does for us is it will just output one or more strings to the browser so it’s really easy to use when you first get going in 

PHP so then we want to create a string and many of you probably know that we use quotes for that so we’re just going to say this is my first script there we go and we close this out with a semicolon now every line that we create is called a statement this is referred to collectively as a statement and this is very similar to other languages like JavaScript and like JavaScript we have to close our statement out with a semicolon and then

 we can start another statement and in turn, it has to be closed out with a semicolon so this is about as basic as we can get so let’s go ahead and save this and then what I want you to do is open up your browser and what we’re going to do is go to 

localhost and I’ve already got it up here as you can see and then you’re just going to type in the name of whatever your document is in my case it’s lesson dot PHP hit enter and there you can see our PHP script ran and we got the output to our browser so this is a good start in the next Articles we will really get going when we will look at variables see you guys .

Categories: PHP

Leave a Reply

Your email address will not be published. Required fields are marked *