Jump to content
xisto Community
Sign in to follow this  
iGuest

Php Tutorial #1 Starting off with the basics.

Recommended Posts

Many people have helped me in learning php, heck if it weren't for a certain someone(not on this site, on legacy-game.net) then i would'nt even be here seeing or posting any of this.
Just a couple of things to be kept in mind, commands/statements we are learning are going to be in bold :

<?phpecho "...";?>

and extra stuff will be in italics and will be explained in detail
------
Now to get started with php, you would need a webhost if you want to directly do things online, otherwise download a localhost server:
-Apache
-Php
-MySQL
You have to get a seperate package of each of these.But it is a pain to hunt for them and then configure seperately, so i suggest you download
WAMP 5 (windows) ...
Linux:LAMP 5

It is a package that comes with all 3 tools .
And it installs and configures quickly!
Simple and easy to use. It has a user friendly index page to keep track of projects..etc and a mysql manager and phpmyadmin.


Considering you have everything,
even basic html is required.
If you dont know,its ok. Ill help
--------------------------------------
PART 2:
Now go to your directory (WAMP 5 default is www folder within WAMP 5 folder ) .

Open up notepad and save has echo.php , file type=All documents (it is originally set on text doc. but change it to all ).
Saved? Good now lets begin basic php.

The opening and closing tags of php that i know of are:
<??>
--
<?php?>
--
we will be using <?php .... ?>.

Now , to display things on the webpage with php, now remember this command. It may seem to be the simplest but it is used for everything, the command is echo "text"; echo $variable; echo "Variable ".$variable." with text";

<?php//echo.php//this is called commenting//these 2 slashes are one line commenters//always use these to comment//helpful for remembering what things//are for.echo "Hello World";$variable="variable";echo $variable;echo "Text ".$variable." text";?>

These are some basic ways to print things on the webpage.
We will go into detail on variables later.

----------------
Part 3:
Ok, now comments are the next most important things :SYNATX : // (one liner comment)
/* comment */ (shell type comment i think)


You can put comments over your codes/pieces of codes to make you remember what they are or how/when they were made.
Its also very helpful in debugging. Suppose you have made an error and you do not know what it is, you simple comment that line at the starting :
before:
echo haha..i didnt put the open and closing tags ;
AFTER:
//echo ....;

and then you can put up another working piece of code and if that comes than that part which you commented is the error.

Commenting helps alot when debugging , remembering, or just working .

Example:
<?phpecho "shhhheewassupppp1"echo "hy wasup!";//no ending semi-colon has been put for the first one.?>
Result:
[blank]
<?php//echo "shhhheeewasspppp1"echo "hy wasup!";?>
Result:
hy wasup!

So you see, it helps in debugging.


The next 3 parts will contain :
-Variables(everything else to, like strings,if else...etc)
-Working with forms
-Basic Mysql Data and structures

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.