PHP is open source scripting language. It\'s widely used to develop web applications.  Home Web Programming PHP PHP : Beginners Guide PT.1

PHP : Beginners Guide PT.1

Browse Pages: 2  3  > >>

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.



Author's URL: Joseph Skidmore
Browse Pages: 2  3  > >>
PHP is open source scripting language. It\'s widely used to develop web applications. More PHP Tutorials: Featured Materials | Fresh Materials | More PHP Tutorials at LearnPHP.org

No comments yet...
Add comments to "PHP : Beginners Guide PT.1"

Captcha