RSS

PHP Function Tutorial – How To Write PHP Functions

Wed, Mar 17, 2010

0 Comments

Working with php functions is pretty simple. A function is basicly just a reference to a peice of php code. We can create a block of code and give it a name then call that name later to run the php code. This helps us by being able to reuse the same code over and over without having to keep wirting the code again and again.

A basic php function looks like this

 <?php

function say($string) {
   echo($string);
}

say(‘blah’);
?>

its basicly that simple. Notice how say is now a reference to echo. We can now use <?php say(‘anything’) ?> over and over again. You might not want to use echo’s since its basicly already a function but you get the idea of how functions work.

Continue reading...

Getting Started With PHP And Learn How To Use It.

Tue, Mar 16, 2010

0 Comments

Hello,

I am going to try to give you some quick steps on how you can start using php. If you are already comfortable with HTML or any other programing language then you should have no problem at all. PHP is a very fun language to work with. The possibility are endless when using php since it is a server side script. This means that all of the code you write in php will be executed on the server (before the page is brought to the visitor).

To get started using php you first need to create a .php document on your web server. You can also rename your existing .html or .htm files to .php files. This will not effect how the html is loaded but will tell the server to exeacaut php code in those files. This is also a good way to tell if your server has php enabled.

To execute php code you must wrap it in <?php and ?>. For example. Try adding <?php echo(‘hello world’); ?> to your document.

Then goto the page and you should now see Hello World where you placed the code. PHP is that simple. I will write up some more tutorials and show you some advanced things you can to with php later.

Continue reading...