Monday, February 4, 2008

ARRAYS

Good Morning Everyone.Am sure you have been practicing on our last tutorial.We talked about; -Installing Necessary applications or softwares to make our lesson easier.Those software are PHP interpreter,MYSQL Database and Apache server. Today,we will be looking at ARRAYS. Arrays are group of items sharing the same characteristics such as CAR MODELS,BASEBALL TEAM and TYPES OF HOUSES.Basically its used to group many variables and stored in to another variable.

CREATING ARRAYS

Arrays can be created like this

$names[0]="Peter"; // Numerical key
$names = array (0 => "julie", 1 => "peter",2 => "mark"); //Numerical key
$names["Friend"]="Sammy"; //words as index key.


You can see from the above examples the various ways arrays are created.The first one has a numerical key which can be referenced like this

echo $names[0];

While,the second one can be referenced, the same way as the first.But the only difference between the first two and the third one,that is the one with a word as its key,is that instead of enclosing 0 in the bracket,we gave it a name which is Friend,so we call it like this

echo $names["Friend"];


As easy as ABC,if you run this,you will get Sammy as your result..

ARRAY()

We can also create arrays with this function.

$languages=array("English","Frenceh","Spanish");


Alternatively,This function can be used to create Assoiciative arrays.An associative array bears a relationship with the value itself.Now lets say we want to specifie relationships to the elements in our previous example.

$names = array ("person1"=> "julie","person2" => "peter","person3" => "mark");

Now you see the difference,we removed the number indexes and changed them to strings.Therefore,the key to julie is "sister".Te reference it is so easy.

echo $names["person1"];. "is". $names["person2"]; ."sister and" . $names["person3"]."bestfriend";

RESULT:Julie is peter sister and mark bestfriend

Now,isnt that easy and interesting?Also,it is very possible to create and array inside an array and it is called a multidimensional Array.For example,Lets say we decided to include the sex,ages of peter,julie and mark in our example,we will do it this way

$names=array("person1"=>array("Age"=>"22","Sex"=>"F"),"person2"=>array ("Age"=>"27","Sex"=>"M "),"person3"=>array("Age"=>"25","Sex"=>"M"));

What we did here is to create another aray in an array,so this is how we reference a multi-dimensional array.


echo $names["person2"]["Age"]; #Result 27

This will display 27 as result.There are so many other ways of outputing array elements.PHP as a large language contains some functions which we will learn.Hope you are having fun!cause i am.

Thursday, January 31, 2008

VARIABLE



VARIABLES

A variable is the name or the object that we assign strings,integers,floats etc to.Php variables always starts with the dollar sign($).Onlike other programming language,you do not need to define the data type.A valid php variable must start with the dollar sign and the name must not start with a number or any other special character apart from alphabets and the underscore sign(_).You can define php variables like this.

VALID:

$variablename="john";
$_variablename="john";
INVALID:
variablename="john";
_variablename="john";
8variablename="john";
$variablename="john";
$8variablename="john";
Variables can be of interger values,strings,floats etc.A string must be surrounded with the " " sign like in examples above but this doesnt apply to intergers.Also,all variables and statements must end (;) sign.

OPERATORS

Php also have operators to perform arithmetic and logical statements.

Operators

+ -Addition
- -Subtration
* -Multiplication
/ -Division
% -Modulus

We all know what they are because we use them everyday of our lives.Note, the modulus operator is quite different.This operator divides two numbers and if there is a remainder,it returs it.Below are examples of this operators

Addition example

x=2;
y=x+4;

ANS:6

Subtraction example

x=2;
y=5;
z=y-x;

ANS:3

Multiplication example

x=4;
x*5;

ANS:20

Division example

x=10;
x=10/2;

ANS:5

Modulus (division remainder)

x=4;
x%3

ANS:1

Increment example(++)

x=5
x++

ANS x=6

Decrement example(++)

x=5
x--

ANS:x=4


WE WILL STOP HER FOR TODAY SO I CAN STUDY THE RESPONSE BE FOR MOVING ON.IF YOU LIKE IT,DONT HESITATE TO LET ME KNOW.

INSTALLING PHP





INSTALLING PHP


Installing php for the first time may seem like a very difficult task for a beginner,which is a very normal situation.
Because,you would have to install so many softwares on your server to be able to perform well with PHP.


Firstly,you will need to install PHP interpreter itself,this is what reads the PHP scripts and processes them and then provides results.

Secondly,you will need to download a webserver to work with php,this is used to interact and process users request.There are various types which i have metioned above.But the most used is the Apache server.After this you will need to set the PHP configuration file to work with the webserver correctly.

Now,lastly,you need a database for PHP to work with,this is where data from users forms,users information are kept and can be sorted for if need arises.For this tutorial we will be using MYSQL.

Basically,a complete beginner can install this packages easily with a third party software like WAMP or XAMPP.
This packages contain all software required to keep start your journey with php,you do not have to worry about the configuration aspect because it will be handled by the all-in-one package.The good thing is that this packages are FREE! and the bad news is...you dont have full control over your system,but as a beginner,who cares.you can download it here Install WAMP or Install XAMPP.

NOW LETS ATTACK PHP

-I assume you have downloaded and have PHP and its server and database working.
to findout,
open your favorite editor,for windows open the notepad and type or copy this in there.





<html>
<body>

<?php
phpinfo();

?>

</body>
</html>


Save it as info.php to your web-server document and open your browser and navigate it to where you saved it.For wamp,you will find it in the dafault folder www.If all settings where done right,you should have a long list of information about our friend php.This means php is set for work.

PHP TUTORIAL FOR THE ABSOLUTE BEGINNER



Name:PHP TUTORIAL FOR THE ABSOLUTE BEGINNER
Difficulty:BEGINNER


ABOUT PHP

PHP is a widely-used and a general purpose scripting language that is capable of
developing first-class and dynamic websites.It is very easy to use or work with as we can embed it into
our HTML codes.Php was designed to make ordinary html codes to perform more.Although php is similar to languages like c and perl.

PHP was first invented in 1995 and its first version which was php3 was release to all in 1998.And now we have PHP5 and soon PHP6 will be released with even more better function and capability.
Php can be run on operating systems like Windows, Linux, Unix, OS

Also,php supports alot of webservers which i will mention a few buth you can get the full documentation on their website http://www.php.net/docs.php

supported webservers:


-Apache {one of the most utilized servers}
-Microsoft IIS
-Personal web server
-omniHTTPd
-and many more

PHP also works with various database to store information gotten from a webpage which we will discuss later.
With php,you can also create a login and signup page which we see on almost all sites on the web.below are some of the supported servers

supported Database:


-Mysql {this is the most used webserver on the web}
-MSSQL(microsoft SQL)
-Postgre
-Oracle
-many more

What php can Do:

-With this great language,you can develope just anything that runs with the internet such as a message board (eg like smf,phbb,etc),you can make a video site like youtube,a gallery like flickr.
-Thats not all that can be done,you can also develope your own yahoo,hotmail and even google.But before you
reach that stage lets first create a helloworld! program.

Next you will know how to install PHP.
NEXT:INSTALLING PHP

Wednesday, January 30, 2008

WELCOME TO TOXICSCRIPTS

Welcome to Toxicscripts.As this is the first post of this New blog about programming both web and desktop,i will like to introduce myself.My name is kennedy Idialu and am from Nigeria,for more info about me,you can check the profile.Ok my main reason for starting a blog like this is that i have seen the power of programmin and to be precised,i love web programming.

Although,i am a newbie(NEW BEGINNER),who wants to learn.I put this on air because i wanted my own community of both skilled and new programmers so that i can ask qestions and larn freely from everyone and also do stuffs with people.

Now,what i plan to do here,is to bring everyone here to learn,teach and give out usefull scripts.so what we will be ding here is basically SUBMISSION of scripts,TUTORIALS any language,Free DOWNLOAD of scripts,ASSIGNMENT PROJECTS and many more.

You can see with the above statements that this place is a place for learnng nd giving so feel free to pop in here and submit something or learn something.We may not have anything to give but we will make sure you are tagged in our HONOURS list with your wensite and othe info.

You can send in tutorials and complete scripts in here mailing me at toxicscripts@gmail.com and then i will paste it in here and we will learn and talk about it together using our every own comments section.

We do not have a registration section here but we you can become one of our members by sending me a mail or by stating it in any comment section,but this is not compulsory.

Ok!All said and done let us begin

(if you like my opening speech,encourage me with your comments)

Design by Dzelque Blogger Templates 2007-2008