PHP : Beginners Guide PT.1

PHP : Beginners Guide PT.1What does PHP stand for?

PHP stands for Hypertext Preprocessor and is used for background programming for web sites.

What can PHP do?

PHP can do many things, such as creating a hit counter, login script, guestbook ... really complex things ... even really easy things such as displaying the time on your page or forwarding a user to a new page (re-direct). The possibilities really are endless.

Enough of this, how do I make my first PHP Page!

As a beginner to PHP you may have searched the web and found the ultimate tutorial on how to start learning PHP;

<?php
echo 'Hello World!';
?>

This script will echo (or print) Hello World! on your page. WOW! We really are going places now ... I think not, this is pretty much useless and tells us nothing. PHP can even colour my code as above ;) As shown in my highlight_string(); tutorial.

I think the best way to start learning PHP is by explaining exactly what it is used for and go through some key points.

Is PHP similar to CSS in regards to how they are used to affect certain parts of the page differently from other sections?

No, CSS styles your page, PHP programs it ... think of all these web design languages like a car, PHP would be the engine running the car while CSS would be the bodywork of the car. You see the difference? One language runs it while the other makes it look good.

HTML is used for placing content in a page and CSS is used for laying out the content in a specific manner to create a desired site/page look. When a url has a .php extension, does that mean the page has been written completely in php or does it mean that it is written in HTML and saved as a .php file?

Good question, if a page has a PHP extension that means it could be anything from having a simple small PHP code inside to being entirely written using PHP ... to include any size PHP scipt on a page, for it to work it must have a .php extension. You can name pages with a .php extension even if they contain no PHP code within, the page does not display any differently.

Does a PHP page (viewed by the public) have to be written in HTML and then add PHP as necessary or can you write a page strictly in PHP?

It depends on how good your memory is really, in my case (very bad) I like to write all the X/HTML first to get the design/layout of the page as I like it and then add the PHP code afterwards. You can write them both together if you like but it all depends on your own personal preferences.

Is there a DOCtype for PHP pages?

I have heard many people ask this question, you would be right for thinking, new language, new doctype ... but no, PHP needs no doctype as it purely depends on what X/HTML you are using the same as if you wasn't using any PHP at all.

Is there a way to validate PHP pages like you would with HTML pages?

No, if your script doesn't work, one way or another you will know about it. Either with an error appearing on screen or your code won't perform the function you want it to. If it works then you know it is valid.

Example of an error

otice: Undefined index: name in c:locationtoindex.php on line 70

Notice: Undefined index: emailurl in c:locationtoindex.php on line 72

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in c:locationtoindex.php on line 87

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:locationtoindex.php on line 89

As you can see, instead of my script performing whatever function it has these are displayed on screen instead, showing you that your code does not work.

How do you start a blank page that will have a .php extension?

Anyway you want, as I mentioned already I like to get the HTML drawn up first and then add the PHP afterwards (easier in my opinion) but again, it depends entirely on your own personal preference.


Related Articles

  • Web Hosting - The Essential Guide For Beginners
    Web hosting is a seemingly complex topic that small business owners can sometimes feel confounded by. When the techie on a message board offhandedly mentions IP addresses, domain names, and the type of hosting plan your business needs, you might be ready to head for the hills!
  • Page Rank - A Quick Overview for Beginners
    Page Rank (PR) is a specific value for a website page given by Google. It is Googles measure of the importance of a certain site page. The scale is between 1-10. Google gives your website high PR if it is popular. Its based on the number of votes other websites give for your website...
  • 5 SEO Techniques For Beginners
    Each page should focus on one keyword or key phrase. Your keyword should appear in the title, the heading tag and one in bold on the page. You can bold one other closely related keyword or phrase, but do not overdo it. Check the keyword density of the page.
  • A Web Hosting Guide for Beginners
    Besides a qualitative web design and unique content your hosting choice might be decisive, so read these tips to be able make a wholistic approach to a site building process.
  • SEO for beginners
    There are literally thousands of websites that are lying there, hidden from the visitors, both potential and casual surfers. This guide deals with the optimization tips for those sites who would want to improve their site ranking...
  • Instant Traffic... or Not
    Let me make one thing clear right now. Even though this is probably one of the most complete, easy to understand tutorials on the subject of promoting your site for beginners, it wont get you instant traffic. You heard right. You wont get people flo...
  • The Importance of SEO for Beginners
    Search engine optimization is a method of increasing the amount of visitors and the awareness of a website by ranking high in the search engines. The higher the rank of a website in the result of the search engines the better the chance the website will be visited by users.
  • A Powerful, Yet Often Overlooked Tip To Improve your Rankings (and it's free)
    With the growing importance of Google this month, you should be thinking about how to garner more quality links to your Web site. Google ranks your page...
  • A Beginners Guide to Server Side Includes
    While much has been written about Server Side Includes (SSIs -also known as Virtual Includes) much of this information is designed for intermediate to advanced webmasters. This article is aimed at beginners...
  • Create a Website - 8 Steps used for Website Creation
    Decided to create a website? Do not register a domain name until you have a website strategy plan. Beginners make the mistake of purchasing a domain before they have started to design their site.

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.