Skip to content

Commit dd38567

Browse files
committed
Initial commit
0 parents  commit dd38567

12 files changed

+358
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

array.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
$title = "Array";
3+
include 'includes/header.php';
4+
?>
5+
<h1><center>Arrays</center></h1>
6+
7+
<?php
8+
9+
// a variable
10+
$num = 3;
11+
12+
// an array
13+
// Only one Datatype
14+
$numbers = array(1,2,3,4,5,6,7,9,11,54,76,98,44,4546,430);
15+
// You can access the value in a subscript of the array using index.
16+
echo $numbers[5];
17+
echo "<p>$numbers[11]</p>";
18+
echo '<hr>';
19+
20+
$size = count($numbers);
21+
echo "<p>Array Numbers is size: $size</p>";
22+
echo '<hr>';
23+
24+
for($count = 0; $count < $size; $count++){
25+
echo "<p>$numbers[$count]</p>";
26+
}
27+
echo '<hr>';
28+
?>
29+
<?php require 'includes/footer.php' ?>

datetimemanip.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
$title = "Date and Time Manipulations";
3+
include 'includes/header.php';
4+
?>
5+
<h1><center>Data and Time Manipulation</center></h1>
6+
7+
<?php
8+
$datenow = getdate();
9+
echo "Today's Date: </br>";
10+
echo $datenow['mday'] . '<br>';
11+
echo $datenow['mon'] . '<br>';
12+
echo $datenow['year'] . '<br>';
13+
echo '<hr>';
14+
echo " Today's Date: " . $datenow['mday'] . '/' . $datenow['mon'] . '/' . $datenow['year'] . '<br>';
15+
echo '<hr>';
16+
17+
print date("m/d/y G.i:s<br>" , time()) . '<br>';
18+
echo '<hr>';
19+
print " Today is ";
20+
print date("j of F Y, \a\\t g.i a", time());
21+
echo '<hr>';
22+
?>
23+
<?php require 'includes/footer.php' ?>

forloop.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
$title = "For Loop";
3+
include 'includes/header.php';
4+
?>
5+
<h1><center>For Loop</center></h1>
6+
7+
<?php
8+
// for loop
9+
for($count = 0; $count < 10; $count++){
10+
echo '<p>HELLO FAIZEE</p>';
11+
}
12+
echo '<hr>';
13+
for($count = 0; $count < 10; $count++){
14+
echo "<p>The Count is : $count</p>";
15+
}
16+
echo '<hr>';
17+
?>
18+
<?php require 'includes/footer.php' ?>

functions.php

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
$title = "Funtions";
3+
include 'includes/header.php';
4+
?>
5+
<h1><center>Functions</center></h1>
6+
7+
<?php
8+
9+
/* Defining a Function */
10+
11+
function writeMessage(){
12+
echo "You are really a nice person, Have a nice time!<br/>";
13+
}
14+
15+
/* Calling a Function */
16+
17+
writeMessage();
18+
19+
echo '<hr>';
20+
21+
writeMessage();
22+
23+
/* Function with parameters */
24+
25+
function addFunction($num1, $num2){
26+
$num = $num1 + $num2;
27+
echo "The sum of $num1 and $num2 is: $num<br/>";
28+
}
29+
30+
/* Pass by Reference - use ampersend in parameter */
31+
function changeNum(&$num){
32+
$num = $num + 10;
33+
// $num+= 10;
34+
}
35+
36+
function returnProduct($num1, $num2){
37+
$prod = $num1 * $num2;
38+
return $prod;
39+
}
40+
41+
$num = 500;
42+
addFunction(10, 32);
43+
addFunction(10, $num);
44+
addFunction('10', "50");
45+
46+
changeNum($num);
47+
echo $num . '<br/>';
48+
49+
$return_value = returnProduct(10, 200);
50+
echo $return_value . '<br/>';
51+
echo '<hr>';
52+
53+
?>
54+
<?php require 'includes/footer.php' ?>

ifstatement.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
$title = "IF Statements";
3+
include 'includes/header.php';
4+
?>
5+
<?php
6+
// An If statement that will carry out an action based on the value of the variable
7+
8+
echo '<h1><center> If Statement </center></h1>';
9+
10+
$Marks = 50;
11+
// ==, ===, >, <, <= , >=,
12+
if($Marks >= 50){
13+
echo '<h3 style="color: green"> YOU HAVE PASSED</h3>';
14+
}
15+
else{
16+
echo '<h3 style="color: red"> YOU HAVE FAILED</h3>';
17+
}
18+
echo '<hr>';
19+
20+
// IF-ELSE IF-ELSE
21+
22+
$grade = 'D';
23+
24+
if($grade == 'A'){
25+
echo '<h3 style="color: green"> YOU ARE A TOPPER</h3>';
26+
}
27+
elseif($grade == 'B'){
28+
echo '<h3 style="color: blue"> YOU DID WELL</h3>';
29+
}
30+
elseif($grade == 'C'){
31+
echo '<h3 style="color: yellow"> AVERAGE</h3>';
32+
}
33+
else{
34+
echo '<h3 style="color: red"> YOU HAVE FAILED...</h3>';
35+
}
36+
echo '<hr>';
37+
?>
38+
<?php require 'includes/footer.php' ?>

includes/footer.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
echo "<p><center> Copyright &copy; 2001-" . date("Y") . " PHP CODE</center></p>";
3+
?>
4+
</div>
5+
<!-- JavaScript Bundle with Popper -->
6+
7+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
8+
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-eMNCOe7tC1doHpGoWe/6oMVemdAVTMs2xqW4mwXrXsW0L84Iytr2wi5v2QjrP/xp" crossorigin="anonymous"></script>
9+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cn7l7gDp0eyniUwwAZgrzD06kc/tftFf19TOAs2zVinnD/C7E91j9yyk5//jjpt/" crossorigin="anonymous"></script>
10+
11+
12+
</body>
13+
</html>

includes/header.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<!-- CSS only -->
8+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
9+
10+
<title>PHP Primer - <?php echo $title ?></title>
11+
</head>
12+
<body>
13+
<div class="container">
14+
<h2><center>Follow each link to the page example</center></h2>
15+
16+
<ul class="nav">
17+
<li class="nav-item"><a class="nav-link" href="index.php">1) Home</a></li>
18+
<li class="nav-item"><a class="nav-link" href="ifstatement.php">2) Simple If Statement</a></li>
19+
<li class="nav-item"><a class="nav-link" href="switchstatement.php">3) Simple Switch Statement</a></li>
20+
<li class="nav-item"><a class="nav-link" href="forloop.php">4) Simple For Loop</a></li>
21+
<li class="nav-item"><a class="nav-link" href="whiledowhileloop.php">5) Simple While / Do While Loop</a></li>
22+
<li class="nav-item"><a class="nav-link" href="array.php">6) Simple array</a></li>
23+
<li class="nav-item"><a class="nav-link"href="stringmanip.php">7) Simple String Manipulation</a></li>
24+
<li class="nav-item"><a class="nav-link" href="datetimemanip.php">8) Simple Date and Time Manipulation</a></li>
25+
<li class="nav-item"><a class="nav-link" href="functions.php">9) Simple Functions</a></li>
26+
</ul>
27+

index.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
$title = "index";
3+
include 'includes/header.php';
4+
?>
5+
<!-- Basic HTML -->
6+
<h1>Faizee Asad</h1>
7+
8+
<?php
9+
// printing to HTML using Echo
10+
echo 'Welcome To PHP ';
11+
echo '<br>';
12+
echo 'HTML TAG';
13+
echo '<br>';
14+
15+
16+
?>
17+
18+
<?php
19+
20+
21+
// declare variable
22+
$name = 'Faizee Asad';
23+
$age = 20;
24+
echo '<hr>';
25+
// print variable
26+
echo $name;
27+
echo '<h1> My Name is : ' .$name.'</h1>';
28+
echo '<h1> My Age is : ' .$age.'</h1>';
29+
echo '<h2> I am '.$age.' years old </h2>';
30+
echo '<hr>';
31+
echo "<h3> MY NAME IS : $name </h3>";
32+
echo "<h3> MY AGE IS : $age </h3>";
33+
echo '<hr>';
34+
35+
?>
36+
<button type="button" class="btn btn-dark">Click Me!</button>
37+
<button type="button" class="btn btn-danger">Click Me!</button>
38+
<button type="button" class="btn btn-warning">Click Me!</button>
39+
<button type="button" class="btn btn-info">IClick Me!nfo</button>
40+
<button type="button" class="btn btn-light">Click Me!</button>
41+
<hr>
42+
<?php require 'includes/footer.php' ?>

stringmanip.php

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
$title = "Strings Manupulations";
3+
include 'includes/header.php';
4+
?>
5+
<h1><center>PHP String Manipulation</center></h1>
6+
7+
<?php
8+
// Concatenation of Strings
9+
$phrase1 = "student who came late";
10+
$phrase2 = "in class, stand with Rock";
11+
echo $phrase1 . ", name Faizee, " . $phrase2;
12+
echo '<br>';
13+
echo '<hr>';
14+
15+
// String transformation
16+
$name = "faizee asad";
17+
echo 'Uppercase first latter: ' . ucfirst($name) . '<br>';
18+
echo 'Uppercase first latter of each word: ' . ucwords($name) . '<br>';
19+
echo 'Upper case : ' . strtoupper($name) . '<br>';
20+
echo 'Lower case : ' . strtolower("FAIZEE ASAD") . '<br>';
21+
echo '<hr>';
22+
echo 'Repeat String: ' . str_repeat('a',10). '<br>';
23+
echo 'Repeat String: ' . strtoupper(str_repeat('a',10)). '<br>';
24+
echo 'Get a Substring ' . substr($name,3, 4). '<br>';
25+
echo 'Get position of String: ' . strpos($name,'f');
26+
echo '<br>';
27+
echo 'Get position of String: ' . strpos($name,'z');
28+
echo '<br>';
29+
// Returns NULL
30+
// echo 'Get position of string: ' . strpos($combine, 'h') . '<br>';
31+
32+
echo 'Find Charater "f": ' . strchr($name, 'f'). '<br>';
33+
echo 'Find Charater "a": ' . strchr($name, 'a'). '<br>';
34+
echo 'Find Charater "z": ' . strchr($name, 'z'). '<br>';
35+
echo 'Find Charater "s": ' . strchr($name, 's'). '<br>';
36+
37+
echo 'Find Lenght of String: ' . strlen($name) . '<br>';
38+
39+
echo 'Without Trim: ' . "A" . " B C D " . "E" . '<br>';
40+
echo 'Trim spaces on both sides: ' . "A" . trim(" B C D ") . "E" . '<br>';
41+
echo 'Trim spaces to the left: ' . "A" . ltrim(" B C D ") . "E" . '<br>';
42+
echo 'Trim spaces to the right: ' . "A" . rtrim(" B C D ") . "E" . '<br>';
43+
44+
echo 'Replace string with another: ' . str_replace("stand", "sit", $phrase2) . '<br>';
45+
echo '<hr>';
46+
47+
?>
48+
<?php require 'includes/footer.php' ?>

switchstatement.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
$title = "Switch Statements";
3+
include 'includes/header.php';
4+
?>
5+
<h1><center>Switch Statements</center></h1>
6+
7+
<?php
8+
9+
$grade = 'B';
10+
11+
switch($grade){
12+
case 'A' :
13+
echo '<h3 style="color: green"> YOU ARE A TOPPER</h3>';
14+
break;
15+
case 'B' :
16+
echo '<h3 style="color: blue"> YOU DID WELL</h3>';
17+
break;
18+
case 'C' :
19+
echo '<h3 style="color: yellow"> AVERAGE</h3>';
20+
break;
21+
default :
22+
echo '<h3 style="color: red"> YOU HAVE FAILED...</h3>';
23+
break;
24+
}
25+
echo '<hr>';
26+
27+
?>
28+
<?php require 'includes/footer.php' ?>

whiledowhileloop.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
$title = "While/Do Whille Loop";
3+
include 'includes/header.php';
4+
?>
5+
<h1><center>While Loop</center></h1>
6+
7+
<?php
8+
$marks = 0;
9+
// Infinite Loop
10+
// while($marks < 10){
11+
// echo '<p> I AM LESS THAN 10!</p>';
12+
// }
13+
14+
// Pre-Condition Loop
15+
while($marks < 10){
16+
echo '<p> I AM LESS THAN 10!</p>';
17+
$marks ++;
18+
}
19+
echo 'EXIT LOOP!';
20+
echo '<hr>';
21+
?>
22+
23+
<h1><center>Do-While Loop</center></h1>
24+
25+
<?php
26+
27+
// Post-Conditions Loop
28+
$marks = 0;
29+
do{
30+
echo '<p> I AM DO WHILE LOOP</p>';
31+
$marks++;
32+
}while($marks < 10);
33+
echo 'EXIT LOOP!';
34+
echo '<hr>';
35+
?>
36+
<?php require 'includes/footer.php' ?>

0 commit comments

Comments
 (0)