- Impact
- 23
PHP is a server side language, and its not like javascript which is a client side language.
Section I - Using PHP
You can run PHP in basically 4 differen't ways.
<%
// Code in here
%>
<script language="php">
// Code in here
</script>
<?
// Code in here
?>
<?php
// Code in here
?>
I prefer the last method "<?php". You also may see "<?" be called shorttags.
Section II - Comments
There are bascically two ways that I do comments within the PHP code, they are:
<?php
// This is a comment
?>
<?php
/* Comment Line 1
Comment Line 2
*/
?>
As you probably can tell, the /* */ combo provides a multi line commenting system, while // privides a single line comment.
Section III - Display HTML
There are two very common ways to display text/html onto the webpage, print and echo. I prefer echo over print.
Example Usage:
print "<b>This is my bold text</b>";
echo "<b>This is my bold text</b>";
You might notice the ; symbol after those lines, its required after every line that you process data.
Section IV - Variables
Heres an example of giving a variable a value:
$name = "Jon";
And using what you learned earier try making it say on the screen:
Your name is Jon
To display variables in echo's or print's do this:
echo "Your name is $name";
or
echo "Your name is " . $name;
Thanks for reading and I hope it helps. Please remember that this is only a Beginning Guide to some simple features of PHP.
Stay tuned in the future for Tutorial #2 that will have how to do some more features.
Section I - Using PHP
You can run PHP in basically 4 differen't ways.
<%
// Code in here
%>
<script language="php">
// Code in here
</script>
<?
// Code in here
?>
<?php
// Code in here
?>
I prefer the last method "<?php". You also may see "<?" be called shorttags.
Section II - Comments
There are bascically two ways that I do comments within the PHP code, they are:
<?php
// This is a comment
?>
<?php
/* Comment Line 1
Comment Line 2
*/
?>
As you probably can tell, the /* */ combo provides a multi line commenting system, while // privides a single line comment.
Section III - Display HTML
There are two very common ways to display text/html onto the webpage, print and echo. I prefer echo over print.
Example Usage:
print "<b>This is my bold text</b>";
echo "<b>This is my bold text</b>";
You might notice the ; symbol after those lines, its required after every line that you process data.
Section IV - Variables
Heres an example of giving a variable a value:
$name = "Jon";
And using what you learned earier try making it say on the screen:
Your name is Jon
To display variables in echo's or print's do this:
echo "Your name is $name";
or
echo "Your name is " . $name;
Thanks for reading and I hope it helps. Please remember that this is only a Beginning Guide to some simple features of PHP.
Stay tuned in the future for Tutorial #2 that will have how to do some more features.
Last edited: