Marc Fraser | Web Design and Development Blog A Web Design and Development Blog by Marc Fraser. Marc Fraser is a student, situated in Central Scotland.

10Oct/090

Create a PHP File and Begin

(from Full Article)

The first thing that all developers need to do is create a blank PHP page. This can be done by simply opening up Notepad and creating a new file – but instead of saving it with the ‘.txt’ affix, change it to ‘.php’. Alternatively, users that have dedicated editors such as Dreamweaver, etc. can create a blank PHP page by selecting File menu and create new PHP page.

Now that we have our blank PHP page we can begin.

Tell the server we wish to begin execution

We have to tell the server that we wish to execute PHP code, otherwise when the user requests the page, nothing dynamic will happen and instead it will just show our PHP code as plain text.

We use ‘<?php’ to start our PHP code and then  ‘?>’ to end. The ‘<?php’ tells the server that the code we wish to start executing is PHP, and ‘?>’ to end executing our PHP code. Outside of these brackets is where our HTML code should go which should not be dynamically updated, such as our Headers, Footers, etc.

You can use the shorthand PHP beginnings (‘<?’) and endings (‘?>’) but this is not recommended as servers do not always support these.

   

Bad Behavior has blocked 66 access attempts in the last 7 days.