Welcome Guest Search | Active Topics | Members

PHP - Basic PHP. Options
rogem002
Posted: Sunday, July 09, 2006 11:54:39 AM

Rank: Martian Estate Agent

Joined: 9/14/2003
Posts: 3,278
Location: United Kingdom
PHP and MySQL are hard at first, though there are loads of websites that show you how to do simple stuff.
I would reccomend http://www.w3schools.com/php/default.asp
This site is a great reffrence and does explain stuff quite well. I've made you a little crash course below :)


Making text appear on the screen,
echo 'Your Text Here';
I lie this think of this as an echo in a cave, you saw it and it will come back!


Using $'s (I forget the name).
$ are a good way to store infomation for example

$mytext = "My Text Here";

Now you have made the $ you can use an echo to make it come on the screen.

echo $mytext;

I'm not going to confuse you to much, but if there is only a $ thingy in a echo you don't put any quotes (' or ") around it. There is a small diffrence between the ' and the ".


Using PHP to do math.
Here's somthing cool you might like, getting php to do math for you (Like a calcuator), first make the $'s.

$number1 = "45";
$number2 = "23";


then to get the server (Or the php) to do the math i like to do

$addednumber = $number1 + $number1

Your can change the + (That adds) to any of the below

/ Divides
* Multiplys
+ Adds
- Subtracts


The if function
I use this for checking forms and so on, it's quite simple (Well to me it is),

if($number1 == "25"){
echo 'I don\'t like the number 25';
}elseif($number1 == "30"){
echo 'I don't like the number 30';
}else{
echo 'The first number is ok!';
}


I like to put == for most of my if's, no idea why..it just works. I put the \ before the ' because in php \means do not process, though i could have put the echo in "". Below is a quick list of all the things an == can be

== Same As
>= Bigger Than
<= Smaller Than

You can change the "" to what ever you want! I've made a quick list below with the diffrent quotes you can use assumeing it's on ==,

$number2 No quotes needed, if it's the name as $number2.
NULL If nothing has been put.
TRUE If there is something in the variable.


the $_REQUEST function
This can be used on forms to get infomation, it works like,
$_REQUEST['form name'];

I like to put them info $'s you can do this by,
[/i]$formname = $_REQUEST['form name'];[/i]


Important stuff
In your php code you need to have <?php starting it and ?> finsihing it.
To make comments you put // Then your comment.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.