Sunday, September 05th, 2010 Welcome Guest! - Register    
Sign In
Forget your password?
Username:  
Password:   
Stay Logged in for:

Donations to date: $62.50
Support This Site Today!

Top 3 Active Posters
Ntsmarkv
SetoTK
mcstec

Latest Forum Posts
dbconfig video guide...

kasl products on sale!...

forum topic...

webhost 2.0...

download page demo's d...

edit post in forum...

portal & users...

webhost 2 language sys...

cosmetic bug : no aft...

forum subtopics...


Forums
Forums
On Sale!
Downloads
Bookmarks
Bookmarks
Contact Us
Contact Us

Sale is Over

The sale in the download's section is now over.


Posted by ~Ntsmarkv on Monday, August 31st, 2010 10:03 PM MST

PHP - Introduction


PHP, The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications (http://www.webasyst.net/glossary.htm). Recently some projects have been started that are porting PHP to be used to write client side programs - just like what you use on your personal computer that is not on the internet.

Rather than rambling on and on about php, this article is going to be written to give you a simple reference of how to perform some simple PHP coding. I will start off by simply showing you how to write content to a page, and how to do it most efficiently. I will show you how to properly comment your code, and how to use variables. How to execute queries to a MySql database and how to display the data from the MySql database.

First off, PHP is an embedded server-side scripting language. This means that it can be placed inside of HTML code and work with it. All PHP code is parsed (executed) on the server so that the only thing sent to a web browser is pure HTML. This is unline JavaScript which is parsed on the client's computer. You can see this if you view the source of a page with a .php extension. All you will see is HTML.

hello.php
---------------------------------------
<?php
  $title 
'hello world!';
?>


Here is the typical HTML content to your page

Here is the title:  <?php echo $title?>

---------------------------------------

To start, we create a page called hello.php. When you write a page that has  PHP language, it needs to have the .php extension so that the server will know to parse the PHP code.

As you can see, the above code is primarily written in HTML. The parts in color are written in php.

Line 1 is the
<?php code that you use to tell the server that you are writing inPHP. It can go anywhere in a HTML page - even above the <html> tags.

Line 2 has $title which is a variable. Variables are words that start with adollar sign ( $ ) that store data that is assigned to them. In this case,
since it says
<?php $title 'Hello World'?> then $title is equal to the string: Hello World!

Line 3 has the closing php tags - this tells the server not to parse PHP again until it sees the opening . remember, you always have to add a
closing
?> tag as well.

Line 6 has the HTML title tags which contain the title of the page - typicalHTML. The only difference is that instead of making the title to say Hello World!, I made it to say $title.  Actually, both of them say the exact same thing when printed or echo'd to the page in your web browser. In this case, since it is in the  will actually be printed to the browser title bar (usually at the top of the browser for Firefox or Internet Explorer, etc.).

Line 10, although in the body of the page that is showing pure HTML, has a little bit of PHP code in it.
<?php echo $title?>, although it looks like it does in the code, it will actually print what was assigned to the $title variable back at the top of the page. It will print Hello World!

The source code for this article is at http://www.kasl.info/source


This page has been accessed 2,462 times     


Search Forums

Articles
PHP - Introduction..

PHP - Comments / Math..

PHP - Work With MySql..

PHP - Login/Logout Scri..

PHP - Track Traffic..

PHP - Who's Online..


Site Stats
Since July 23, 2005:
1,075,802 hits
783,208 unique visitors
Today's Info:
225 hits
74 unique visitors
More Traffic Stats

Who's Online: Active
Users: 0
Guests: 75
Truncate Online Users:

KASL Members:
Currently 2,539
Newest member: Gilues
Forum Stats:
There are 9 categories
There are 16 topics
There are 67 posts
Page Load Time
Page loaded in 0.027 secs.