Joomla CMS (Content Managment Cystem), Joomla CMS Templates and Modules


 
JOOMLA CHANNELS
Home
Joomla Downloads
Joomla Components
Joomla Modules
Joomla Templates
Top Downloads
Joomla CMS tutorials
Joomla Directory
Webmaster Tutorials
Joomla News
Joomla Sitemap
Link to us
Advertise with us
Other CMS
PHP Nuke
Post Nuke
Login Form





Lost Password?
No account yet? Register
Joomla Network
MySpace Editors
Get Joomla Traffic
ZillR Social Network
Linkzee Directory
99cent Link Directory
Myspace Editors
Free Web Hosting
Links Directory
Free Myspace Proxy
Free Web Proxy
Free Online Dating
Myspace Tweak
Myspace Graphic
Joomla templates

To see the demo of the template click on the template image, to download the template you must be logged in.


Final Notes
User Rating: / 1
PoorBest 
Written by Administrator   
Monday, 17 October 2005
In the past 6 parts of this tutorial I have shown you the basics of writing PHP. In this final part I will show you a few small things which don't really warrant a section of their own.

Comments

As with any programming language, it is quite important to comment in your script. If you are working on a script with someone else you must let them know what you code does and if you are distributing your script you will need to show people how to edit it. Even if you are the only one who will use your script it is useful to comment so that you can edit it at a later date.

In PHP there are two ways you can comment. One way is used for single line comments and the other is used mainly for comments that go over one line. A single line comment is written as follows:

// Your comment can go in here

Everything after the // will be ingnored when the script is executed. You can even place these on the end of another line e.g.

print "Hello $name"; // Welcome to the user

Another way of commenting is by using multi-line comments:

/* The following piece of code will take the input
the user gave and will check that it is valid before
adding it to the database */

Anything between the /* and the */ will be ignored. It is important that you always close this type of comment as not doing so could make your script not work.

Print, Echo and HTML

As you may have noticed during this tutorial I have actually used 4 different ways of outputting information to the browser:

echo("Text here");
echo "Text here";
print("Text here";
print "Text here";

To clarify, all of these do the same thing and you can use any or all of them in a script. There is no reason to even use the same type all through a script. The only problem you may find is that, as I explained in part 2, all the " in the HTML code must be replaced with \" which, if you have a lot of code, could take a very long time. This brings me to a very useful part of PHP. If, for example, you created the header of a page dynamically in PHP, then had the static page and finally a dynamic footer you can do the following:

<?
Top PHP code in here
?>
HTML Code
<?
Bottom PHP code in here
?>

This gets even better as the PHP code will just continue from where it was left off so you could do the following:

<?
IF Statement {
?>
HTML For IF Being Correct
<?
} else {
?>
HTML For IF Being Wrong
<?
}
?>

You must always remember to close IF statements and loops, though, as it is very easy to forget.

One Line Prints

Being able to place HTML code into your PHP is very useful, but what happens if you want to put the value of a variable into the code. Unlike when using an echo or print statement, you can't just put in the variable name as this section is not actually part of the PHP code. Instead you must just put in a little PHP.

For example if you wanted to print someone's name from a script with HTML formatting you would do the following:

<font face="Arial" size="7" color="red"><b><? echo($variablename); ?></b></font>

In the above code you have just added in the following PHP:

<? echo($variablename); ?>

Which is exactly the same as the following PHP code:

<?
echo($variablename);
?>

But all put onto one line.

Conclusion

This tutorial has given you some of the basics of PHP and should allow you to do most things you will want to. For a much more in depth look you should visit PHP.net, the official homepage of PHP. One major omission of this tutorial, you may have noticed, is using PHP with a database. As this is one of the major reasons that people use PHP and because there are many options
I will put this in a separate PHP/MySQL tutorial.

Comments

Only registered users can write comments.
Please login or register.

Powered by AkoComment 2.0!

 
< Prev   Next >
 
Who's Online
We have 114 guests online and 1 member online
Syndicate
JoomlaResource.com Latest News
SUPPORT JOOMLARESOURCE

Please help us keep this site live by helping with hosting costs.

Donate Once Monthly

Currency

Amount

Currency

Amount

Advertisers
Polls
How did you Find us?
 
Main Sponsors
30GB Free Webmail Account
Home Loan uk
BluePortal Ebook Resources
Joomla Traffic
Online Petition
Web Hosting
cpanel hosting
Advertise Here
Loans
Shopping Cart Software
Joomla Hosting
FUNNY Videos
Learn Spanish Online


All rights reserved. All other trademarks appearing on on this site are the property of their respective owners. We do not endorse contents submitted by our users. We are not affiliated with any 3rd party trademark material in any way. Thona Network directs full legal responsibility of contents to their respective owners/users. Thona Network is not responsible for the contents of any uploaded files,images, and other web contents, nor is it affiliated with entities represented in the uploaded files.


eXTReMe Tracker