Intro to PHP tutorial
Author: Bill Trikojus
![]() |
|
![]() |
|
![]() |
|
*NOTE: This tute is aimed at people who already have a good understanding of Actionscript.
![]() |
|
|
|
|
![]() |
|
|
And here is what it would look like in PHP $i=56;So as you can see it's almost identical except for the fact that variables in php must be prefixed with a $. Another thing to note is that PHP is much stricter than actionscript and will fail if you forget to put the ; at the end of each line. //do stuff } Again, very similar to actionscript (//comments are the same as well) and then access an element from that array $mum=$names[2];To get the length of the array you use count(); which in our example would make $theLength variable = 3 would output Would output //some php ?> The php in your website will often appear within straight html content <head><title>My php page</title> </head> <body> <? $a=5; $b=6; $theImage="images/test.jpg"; $displayImage=true; $theSum=$a + $b; echo "5 + 6 = " . $theSum . "<br>"; ?> Above is a line of text that was output from php. <br> <? if($displayImage){ ?> Here is an image<br> <img src="<? echo $theImage; ?>"><br> <? }else{ ?> I don't want to show you my image <? } ?> </body> </html> As you can see, you can jump in between php and html as many times as you like throughout a page. |
|
![]() |
|
|
some text and <? include 'moretext.php'; ?> and some more text </body> This will grab the contents of moretext.php and insert it into the middle of this html page. What this means is that you can break up a site into little parts (header, menu, content, footer etc) and then compile them as the page is loaded. If all pages on your site are getting their menu from menu.php then only one file needs to be updated for all the page change. Like CSS, this saves time and ensures consistent design. everything after the ? gets sent to PHP in a $_REQUEST array and it can then extract the value like so $thePage=$_REQUEST['page'];You can string together as many variables as you like (within reason) main.php?page=page34&mood=grumpy&pet=phlappyOK that's a quick intro to PHP. I hope you can see how powerful it is. I've provided a hit counter example as well so have a look at that to see how PHP can open files, read them and even write to them (note: to do this, the file must have write permissions turned on). You can download these examples here.Your task now is to make a page that includes php. It can be a form, a file uploader, a search engine - anything you want. The more complex it is - the more you will learn. |
|
Share
Like this? Click a link below to share it...Subscribe and Download

Post a comment
Garbage posts and SPAM will be deleted.



