0% found this document useful (0 votes)
13 views10 pages

PHP First LCTR DR - RMT

The document provides instructions for setting up a PHP development environment and covers various PHP concepts like basic tags, variables, arrays, and operators. It includes code examples for printing text, declaring variables, accessing array elements, and using different operator types. The sender provides step-by-step guidance to the recipient on creating PHP files and testing code samples within a local development setup.

Uploaded by

abduldahiru227
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views10 pages

PHP First LCTR DR - RMT

The document provides instructions for setting up a PHP development environment and covers various PHP concepts like basic tags, variables, arrays, and operators. It includes code examples for printing text, declaring variables, accessing array elements, and using different operator types. The sender provides step-by-step guidance to the recipient on creating PHP files and testing code samples within a local development setup.

Uploaded by

abduldahiru227
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

[12/17, 6:24 AM] Al AMEEN CYPRUS: *Course outlines*

1. Introduction To PHP

2. Basic Tags In PHP

3. PHP Operators

4. Conditional statements, Switch statements

5. PHP Arrays

6. PHP Loops

7. PHP Functions

8. GET & POST

9. SESSION & COOKIE

10. Sign up form with PHP validations

[12/17, 6:24 AM] Al AMEEN CYPRUS: To run php in your computer you will need to download XAMPP for
windows, Linux or even for IOS operating systems, just specify any you wish. After downloading you will
have to install it in your computer and run it. You will have to enable the following as they appear in
image below; make sure it indicates running,

Then you will have to download any of the text editor either, notepad++, brackets, visual studio code,
sublime text, among others.
[12/17, 6:24 AM] Al AMEEN CYPRUS: Let start with the introduction

[12/17, 6:24 AM] Al AMEEN CYPRUS: After you install your text editor you will go to the search label in
your computer and search for xampp htdocs then open that folder then create a new folder you may
name it as, “myproject”, then drag and drop it in your text editor.

[12/17, 6:24 AM] Al AMEEN CYPRUS: Open it and delete all the content Inside

[12/17, 6:24 AM] Al AMEEN CYPRUS: Are you done?

[12/17, 6:25 AM] Al AMEEN CYPRUS: Create a new folder with name myproject

[12/17, 6:25 AM] Al AMEEN CYPRUS: Start the xampp

[12/17, 6:25 AM] Al AMEEN CYPRUS: Om open the folder and create a file with name index.php

[12/17, 6:25 AM] Al AMEEN CYPRUS: Open sublime

[12/17, 6:25 AM] Al AMEEN CYPRUS: Click on the myproject

[12/17, 6:25 AM] Al AMEEN CYPRUS: You need to be fast honestly

[12/17, 6:25 AM] Al AMEEN CYPRUS: Don't forget there is no space

[12/17, 6:25 AM] Al AMEEN CYPRUS: Browse and Save the empty file at htdocs inside myproject folder
with 11.php

[12/17, 6:25 AM] Al AMEEN CYPRUS: Ok open the browser on new tab and type this

[12/17, 6:25 AM] Al AMEEN CYPRUS: 11.php should be name of the file

[12/17, 6:25 AM] Al AMEEN CYPRUS: Good this is how to create a file

[12/17, 6:25 AM] Al AMEEN CYPRUS: localhost/myproject/11.php

[12/17, 6:25 AM] Al AMEEN CYPRUS: Ok try and create as many files as you can

[12/17, 6:25 AM] Al AMEEN CYPRUS: We will start the coding tomorrow

[12/17, 6:25 AM] Al AMEEN CYPRUS: Will you mind if I give you lecture now?

[12/17, 6:25 AM] Al AMEEN CYPRUS: *Basic Tags In Php Programming Language*

[12/17, 6:25 AM] Al AMEEN CYPRUS: *1.* First you will need to type the following codes in your html
program in between body tags as;

[12/17, 6:25 AM] Al AMEEN CYPRUS: Open a php.11 and type html it will complete the rest of the tag for
you
[12/17, 6:25 AM] Al AMEEN CYPRUS: Here is the code

[12/17, 6:25 AM] Al AMEEN CYPRUS: *Note* every php program start with <?php as open tag and end
with. ?>

[12/17, 6:25 AM] Al AMEEN CYPRUS: <!DOCTYPE html>

<html>

<head>

<title>my document title</title>

</head>

<body>

<?php

your content here

?>

</body>

</html>

[12/17, 6:25 AM] Al AMEEN CYPRUS: Let me see when you're done

[12/17, 6:25 AM] Al AMEEN CYPRUS: After you type those codes you can now go ahead and start your
programming using php language, for instance.

[12/17, 6:25 AM] Al AMEEN CYPRUS: Every time your using php make sure your xampp is on

[12/17, 6:25 AM] Al AMEEN CYPRUS: Now, replace your name with this <?php

php info();

?>

[12/17, 6:25 AM] Al AMEEN CYPRUS: Run

[12/17, 6:25 AM] Al AMEEN CYPRUS: Every time your running php

[12/17, 6:25 AM] Al AMEEN CYPRUS: Click on the my project folder

[12/17, 6:25 AM] Al AMEEN CYPRUS: Just type localhost on your browser

[12/17, 6:25 AM] Al AMEEN CYPRUS: From browser


[12/17, 6:25 AM] Al AMEEN CYPRUS: Change the program to

[12/17, 6:25 AM] Al AMEEN CYPRUS: echo "hello world";

[12/17, 6:25 AM] Al AMEEN CYPRUS: Inside thevtwg

[12/17, 6:25 AM] Al AMEEN CYPRUS: The tag

[12/17, 6:25 AM] Al AMEEN CYPRUS: echo means print

[12/17, 6:25 AM] Al AMEEN CYPRUS: To that case it will produce all information about php installed into
that computer

[12/17, 6:25 AM] Al AMEEN CYPRUS: You're doing well

[12/17, 6:25 AM] Al AMEEN CYPRUS: Try and practice this before I come back from meeting

[12/17, 6:25 AM] Al AMEEN CYPRUS: You can change the hello world with anything you like

[12/17, 6:25 AM] Al AMEEN CYPRUS: $name="philloh";

echo "my name is $name";

[12/17, 6:25 AM] Al AMEEN CYPRUS: Let’s now look at the variables- is a symbol or name that stands for
a value, for example to use variables you will type the following in between php tags.

[12/17, 6:25 AM] Al AMEEN CYPRUS: $name="Aminu";

$school="schoolname".

[12/17, 6:25 AM] Al AMEEN CYPRUS: I want you to follow this format and declare a variable with your
details

1. Name

2. School

3. Department

4. Course
And others

[12/17, 6:25 AM] Al AMEEN CYPRUS: But first declare the variable before you echo them

[12/17, 6:25 AM] Al AMEEN CYPRUS: After then you use echo to print them

[12/17, 6:25 AM] Al AMEEN CYPRUS: *Use Of Arrays In Php Language*

[12/17, 6:25 AM] Al AMEEN CYPRUS: To add comment in php program you will have to use, // forward
slashes or # before your content as // echo “hello world”; the text will appear as a comment. But if you
wish to enclose a certain text you will type this; /* your content */ all content between those signs will
appear as a comment.

[12/17, 6:25 AM] Al AMEEN CYPRUS: Variables always starts with a letter A-z or underscore (_) then
followed by other letters or numbers. For instance, $9name is not valid but this $_9name is valid.

[12/17, 6:25 AM] Al AMEEN CYPRUS: *For instance;*

<?php

$cars=array("BMW","AUDI","MERCEDEZ");

echo $cars[1];

?>

It will output AUDI

[12/17, 6:25 AM] Al AMEEN CYPRUS: *Definition*

First we do you ask yourself what an array? Array– is a data structure that contains a group of elements,
typically these elements are all of the same data type, such as an integer or a string, arrays are
commonly used in computer programs to organize data so that a related set of values can be easily
sorted or searched. Then you start numbering your arrays from zero (0) and then numbering continues.

[12/17, 6:25 AM] Al AMEEN CYPRUS: *ASSOCIATE ARRAYS*

As the name suggests you associate your arrays with their values for instanceare you may associate a
certain car with its average speed it moves with. You associate arrays with use of this sigh equal or
greater than(=>) For example;

[12/17, 6:25 AM] Al AMEEN CYPRUS: echo $cars[2]?

echo $cars[3]?
[12/17, 6:25 AM] Al AMEEN CYPRUS: *MULTIDIMENSIONAL ARRAYS*

As the name suggests this type of makes one use multiple arrays in the same program code, for
instance,

[12/17, 6:25 AM] Al AMEEN CYPRUS: <?php

$cars=array("Audi"=>40.25,"BMW"=>34.78,"Mercedes"=>50.75);

//to output the average speed for Mercedes you will type this

echo $cars["Mercedes"];

?>

[12/17, 6:25 AM] Al AMEEN CYPRUS: <?php

$cars=array("expensive"=>array("Audi", "Mercedes", "BMW"), "inexpensive"=>array(Toyota", "Suzuki",


"ford"));

echo $cras["expensive"][1];

?>

It will output

Mercedes

You may using other values and see the results for better understanding

[12/17, 6:25 AM] Al AMEEN CYPRUS: *Use Of Operators In PHP Programming Language*

[12/17, 6:25 AM] Al AMEEN CYPRUS: In our last lecture we discussed use of arrays in php programming
language; now we are going deeper into php programming language as we will be discussing very basic
part of it which is various types of operators used.

[12/17, 6:25 AM] Al AMEEN CYPRUS: each programming language there is use of operators which are
categorized as below;

*1. Arithmetic operators*

*2. Assignment operators*


*3. Comparison operators*

*4. Logical operators*

[12/17, 6:25 AM] Al AMEEN CYPRUS: We will now discuss each in detail;

*Arithmetic operators*

addition (+)

subtraction (-)

multiplication (*)

division (/)

percentage (%)

[12/17, 6:25 AM] Al AMEEN CYPRUS: for instance, a syntax for arithmetic operators; remember the
codes should be written in between php tags,

[12/17, 6:25 AM] Al AMEEN CYPRUS: Assignment operators

add and assign (+=)

subtract and assign (-=)

multiply and assign (*=)

divide and assign (/=)

concatenate and assign (.=)

for instance, let’s have a syntax for assignment operators

[12/17, 6:25 AM] Al AMEEN CYPRUS: <body>

<?php

$x=5;

$y=6;

$total=$x+$y;

echo $total

?>
</body>

It will produce 11

You may use different operator and variable and try it yourself

[12/17, 6:25 AM] Al AMEEN CYPRUS: For instance, let’s have a syntax for a comparison operator,

<body>

<?php

$x=10;

$y=7;

if($x>&y){

echo "this is true";

}else{

echo "this is false";

?>

</body>

It will produce this is true

[12/17, 6:25 AM] Al AMEEN CYPRUS: *Comparison operator*

These operators are used to compare different variables as per the condition; they include;

Greater than (>)

Less than (<)


Less than or equal to (<=)

Greater than or equal to (>=)

Equal (==)

Not equal (!=)

[12/17, 6:25 AM] Al AMEEN CYPRUS: <body>

<?php

$x=5;

$y=6;

echo $x-=$y;

?>

</body>

It will produce -1

You may use different variables and operator and try it yourself

[12/17, 6:25 AM] Al AMEEN CYPRUS: Logical operators

They include;

Pre-increment (++$x)

Post-increment ($x++)

Pre-decrement (–$x)

Post-decrement ($x–)

And/&&- both x and are true

Or/||- either x or y are true

Xor- either x or y are both not true


!- true if x is not true

[12/17, 6:25 AM] Al AMEEN CYPRUS: For instance, let’s have a syntax for logical operators,

<body>

<?php

$x10;

echo $x-;

echo "<br>";

echo $x;

?>

</body>

It will produce 9

You may use different operator and variable and try it yourself.

[12/17, 6:27 AM] Al AMEEN CYPRUS: *Assignment*

1. Create two variables(x,y) add them ad multiply answer by 6. Print your answer as a variable ‘z’.

2. Define two variables(name,age) and print out in form of a statement telling us your name and age.

3. Create an array that shows capital cities of any 3 countries.

4. Create two variables(price,vat). Create a new variable ‘totalPrice’ then calculate the vat on the price
and print out the(vat,price,total Price).

You might also like