Rhys
28-01-2010, 11:30 PM
one of the first ever things you will/should learn is Echo in php
its extremely simple once you get to know it and easy to learn, but theres a few bits which you need to learn.
---
Right now to show the most simple form of an echo.
<?PHP
echo "This will be shown on the page";
?>
Now in a little detail
<?PHP
This will open the php script
echo "This will be shown on the page";
echo tells the script to show what is put in "..". its like the body of a html file but put into php. ; will tell the script to go onto the next line or variable.
?>
this closes the php script.
now thats the easiest thing you could ever do and it'll show just the text youve put in between "..".
Now to get onto the more complicated bits and to make the text formated.
Now if u wanted you could simply do this by adding a css bit like
<div
style="
font-family: Verdana;
font-size: 12px;
">
now its not always that easy to implament it, if you showed it like this in the php it wouldnt work.
<?PHP
echo "<div style="font-family: Verdana; font-size: 12px;">This will be shown on the page</div>";
?>
No ofcourse php made it all complicated.
If you open and echo tag with ", it must not have anouther in the way, this will make php think that the code has ended and the rest of the script will not be included untill it is opened again. It can also be done with '..' . Its confusing and will make you think but i believe most should get used to it after a while.
For it to work it should be outputted like this
<?PHP
echo "<div style=\"font-family: Verdana; font-size: 12px;\">This will be shown on the page</div>";
?>
OR
<?PHP
echo "<div style='font-family: Verdana; font-size: 12px;'>This will be shown on the page</div>";
?>---
Have a little practice and get used to using php and having to use \'s and then finally then we can get onto using strings
---
Strings are good if u want to write out something but dont want to show it till later.
Strings use $'s. after the $'s they have a name. lets call ours $show1 and $show2.
Showing both is a piece of cake.
<?PHP
$show1 = "<b>This is the first line</b><br />";
$show2 = "This is the second line";
echo "Read below<br /><br />";
echo $show1;
echo $show2;
?>
That will show what you put in the string show1 and show2 + above it Read Below.
lets say you put something important in $show1 but dont wana show it and put a date till u show it on $show2 then u simply dont echo $show1. and when u want to. only echo $show1 and not $show2.
I think you may be a little confuzed atm but make yourself a few php pages and go threw trying a few techniques with the normal echoing onto the string echoing and it should be a doddle.
Ill do anouther tut soon on php.
Hope you learnt something new and any q's, just ask :D
I wrote this along time ago, well back in feb last year. If u do get a bit confused with how i wrote it (since i was just starting out then) then do feel free to comment
its extremely simple once you get to know it and easy to learn, but theres a few bits which you need to learn.
---
Right now to show the most simple form of an echo.
<?PHP
echo "This will be shown on the page";
?>
Now in a little detail
<?PHP
This will open the php script
echo "This will be shown on the page";
echo tells the script to show what is put in "..". its like the body of a html file but put into php. ; will tell the script to go onto the next line or variable.
?>
this closes the php script.
now thats the easiest thing you could ever do and it'll show just the text youve put in between "..".
Now to get onto the more complicated bits and to make the text formated.
Now if u wanted you could simply do this by adding a css bit like
<div
style="
font-family: Verdana;
font-size: 12px;
">
now its not always that easy to implament it, if you showed it like this in the php it wouldnt work.
<?PHP
echo "<div style="font-family: Verdana; font-size: 12px;">This will be shown on the page</div>";
?>
No ofcourse php made it all complicated.
If you open and echo tag with ", it must not have anouther in the way, this will make php think that the code has ended and the rest of the script will not be included untill it is opened again. It can also be done with '..' . Its confusing and will make you think but i believe most should get used to it after a while.
For it to work it should be outputted like this
<?PHP
echo "<div style=\"font-family: Verdana; font-size: 12px;\">This will be shown on the page</div>";
?>
OR
<?PHP
echo "<div style='font-family: Verdana; font-size: 12px;'>This will be shown on the page</div>";
?>---
Have a little practice and get used to using php and having to use \'s and then finally then we can get onto using strings
---
Strings are good if u want to write out something but dont want to show it till later.
Strings use $'s. after the $'s they have a name. lets call ours $show1 and $show2.
Showing both is a piece of cake.
<?PHP
$show1 = "<b>This is the first line</b><br />";
$show2 = "This is the second line";
echo "Read below<br /><br />";
echo $show1;
echo $show2;
?>
That will show what you put in the string show1 and show2 + above it Read Below.
lets say you put something important in $show1 but dont wana show it and put a date till u show it on $show2 then u simply dont echo $show1. and when u want to. only echo $show1 and not $show2.
I think you may be a little confuzed atm but make yourself a few php pages and go threw trying a few techniques with the normal echoing onto the string echoing and it should be a doddle.
Ill do anouther tut soon on php.
Hope you learnt something new and any q's, just ask :D
I wrote this along time ago, well back in feb last year. If u do get a bit confused with how i wrote it (since i was just starting out then) then do feel free to comment