├── L2-Variables.php ├── test.txt ├── test2.txt ├── L28-request-response.php ├── File inclusion ├── footer.php ├── index.php └── header.php ├── uploads └── IMG-668f948d0b4a3.pdf ├── session ├── logout.php ├── index.php └── login.php ├── L6-Uses_of_Quotes.php ├── L5-comments.php ├── L4-Constants.php ├── L21-File-inclusion.php ├── L24-Error-Handling.php ├── hw ├── first homework │ ├── protikha │ │ ├── ass-6.php │ │ ├── ass-3.php │ │ ├── ass-5.php │ │ ├── ass-7.php │ │ ├── ass-4.php │ │ ├── ass-1.php │ │ └── ass-2.php │ └── AIMAN PHP Homework 1 │ │ ├── L6_odd_even.php │ │ ├── L3_vote_eligible.php │ │ ├── L7_string_int_checker.php │ │ ├── L5_positive_checker.php │ │ ├── L4_marriage_eligible.php │ │ ├── L1_electric_bill.php │ │ └── L2_calculator.php └── protikha6-06-2024 │ └── homework.php ├── L1-echo.php ├── L10-Loops.php ├── L23-try-catch-throw-finally.php ├── L15-function.php ├── L13-random-pass.php ├── L26-JSON.php ├── L22-Sending-mail.php ├── L18-2-methods.php ├── L3-Data_types.php ├── L14-strings.php ├── L7-operators.php ├── L8-Mathematical_functions.php ├── L16-regular-expression.php ├── L31-opp-class.php ├── L20-file-upload.php ├── L18-1-superglobals.php ├── L25- Date-Time.php ├── L32-oop-part-2.php ├── L27-File-system.php ├── L9-Control_Statements.php ├── L29-crud.php ├── L12-Array-functions.php ├── L30-session.php ├── L11-Arrays.php ├── L33-oop-part-3.php ├── L17-problem-solving.php └── L19-form-validation.php /L2-Variables.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | Hello PHP 3 | Hello Laravel -------------------------------------------------------------------------------- /test2.txt: -------------------------------------------------------------------------------- 1 | Hello World 2 | Hello PHP 3 | Hello Laravel -------------------------------------------------------------------------------- /L28-request-response.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /File inclusion/footer.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /uploads/IMG-668f948d0b4a3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asif-daffodil/B83mPHP/HEAD/uploads/IMG-668f948d0b4a3.pdf -------------------------------------------------------------------------------- /session/logout.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /L6-Uses_of_Quotes.php: -------------------------------------------------------------------------------- 1 | "; 4 | echo 'Hello, $city
'; 5 | ?> -------------------------------------------------------------------------------- /L5-comments.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /File inclusion/index.php: -------------------------------------------------------------------------------- 1 | 4 | 5 |

Home page

6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /L4-Constants.php: -------------------------------------------------------------------------------- 1 | "; 4 | 5 | $x = 231; 6 | 7 | define("x", 321); 8 | 9 | echo $x."
"; 10 | echo x."
"; 11 | ?> -------------------------------------------------------------------------------- /L21-File-inclusion.php: -------------------------------------------------------------------------------- 1 | 4 | 5 |

Page Content

6 | 7 | -------------------------------------------------------------------------------- /L24-Error-Handling.php: -------------------------------------------------------------------------------- 1 | "; 7 | } 8 | ?> 9 | -------------------------------------------------------------------------------- /hw/first homework/protikha/ass-6.php: -------------------------------------------------------------------------------- 1 | ", "Hi, PHP!
"; 3 | // print "ha ha ha", "he he he"; 4 | 5 | if(print("Hello, World war 2!
")) { 6 | echo "Hello, World!
"; 7 | } 8 | 9 | var_dump(123); 10 | -------------------------------------------------------------------------------- /hw/first homework/AIMAN PHP Homework 1/L6_odd_even.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hw/first homework/protikha/ass-3.php: -------------------------------------------------------------------------------- 1 | = 18) { 4 | return "Eligible to vote"; 5 | } else { 6 | return "Not eligible to vote"; 7 | } 8 | } 9 | 10 | echo checkVoterEligibility(25) . "\n"; 11 | -------------------------------------------------------------------------------- /L10-Loops.php: -------------------------------------------------------------------------------- 1 | "; 8 | 9 | for($i = 0; $i < 5000; $i++){ 10 | if($i >= 533 && $i % 533 == 0){ 11 | echo $i."
"; 12 | } 13 | } 14 | ?> -------------------------------------------------------------------------------- /hw/first homework/protikha/ass-5.php: -------------------------------------------------------------------------------- 1 | 0) { 4 | return "Positive"; 5 | } elseif ($num < 0) { 6 | return "Negative"; 7 | } else { 8 | return "Zero"; 9 | } 10 | } 11 | 12 | echo checkNumber(-5) . "\n"; 13 | -------------------------------------------------------------------------------- /hw/first homework/protikha/ass-7.php: -------------------------------------------------------------------------------- 1 | = 18){ 5 | return "Eligible to vote"; 6 | }else { 7 | return "Uneligible to Vote"; 8 | } 9 | } 10 | 11 | echo voterEligibilityChecker(43); 12 | ?> -------------------------------------------------------------------------------- /session/index.php: -------------------------------------------------------------------------------- 1 | 7 |

Welcome

8 |

Your name is : and your city is :

9 |
10 | Logout -------------------------------------------------------------------------------- /File inclusion/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |
10 | Header 11 | 12 |
-------------------------------------------------------------------------------- /L23-try-catch-throw-finally.php: -------------------------------------------------------------------------------- 1 | = 5){ 5 | throw new Exception('This is an exception'); 6 | } 7 | echo 'This is not an exception
'; 8 | }catch(Exception $e){ 9 | echo 'Message: '.$e->getMessage()."
"; 10 | }finally{ 11 | echo 'Finally block'; 12 | } 13 | 14 | ?> -------------------------------------------------------------------------------- /hw/first homework/AIMAN PHP Homework 1/L7_string_int_checker.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /hw/first homework/AIMAN PHP Homework 1/L5_positive_checker.php: -------------------------------------------------------------------------------- 1 | = 0) { 7 | return "The number is positive"; 8 | }else { 9 | return "The number is negative"; 10 | } 11 | } 12 | 13 | echo positiveChecker(-21); 14 | 15 | ?> -------------------------------------------------------------------------------- /L15-function.php: -------------------------------------------------------------------------------- 1 | "; 4 | } 5 | 6 | echo shoeMyName("Protikkha", "Tanwi"); 7 | echo shoeMyName("Aiman", "Ghazi"); 8 | echo shoeMyName(); 9 | echo shoeMyName("Mujhaid"); 10 | echo shoeMyName(myLastName:"Boyati", myFirstName:"Mujhaid"); 11 | ?> -------------------------------------------------------------------------------- /hw/first homework/protikha/ass-4.php: -------------------------------------------------------------------------------- 1 | = 21 && $gender == 'male') { 4 | return "Eligible for marriage"; 5 | } elseif ($age >= 18 && $gender == 'female') { 6 | return "Eligible for marriage"; 7 | } else { 8 | return "Not eligible for marriage"; 9 | } 10 | } 11 | 12 | echo checkMarriageEligibility(20, 'male') . "\n"; 13 | -------------------------------------------------------------------------------- /L13-random-pass.php: -------------------------------------------------------------------------------- 1 | ?"; 6 | 7 | echo str_shuffle(substr(str_shuffle($capAlpha), -2).substr(str_shuffle($smallAlpha), -2).substr(str_shuffle($numbers), -2).substr(str_shuffle($specialChars), -2).uniqid().rand(1000, 9999)); 8 | 9 | // numeric functions 10 | 11 | ?> -------------------------------------------------------------------------------- /hw/first homework/AIMAN PHP Homework 1/L4_marriage_eligible.php: -------------------------------------------------------------------------------- 1 | =21)){ 5 | return "Man is eligible to marry"; 6 | }elseif (($gender == 'Female') && ($age >=18)){ 7 | return "Woman is eligible to marry"; 8 | }else { 9 | return "Ineligible to marry"; 10 | } 11 | } 12 | 13 | echo marriageEligibilityChecker('Female', 25); 14 | ?> -------------------------------------------------------------------------------- /L26-JSON.php: -------------------------------------------------------------------------------- 1 | 'Abir', 6 | 'age' => 25, 7 | 'city' => 'Dhaka', 8 | 'country' => 'Bangladesh' 9 | ]; 10 | 11 | echo json_encode($arr)."
"; 12 | 13 | // json 14 | $json = '{"name":"Abir","age":25,"city":"Dhaka","country":"Bangladesh"}'; 15 | $arr = json_decode($json, true); 16 | echo "
";
17 |     print_r($arr);
18 |     echo "
"; 19 | 20 | ?> -------------------------------------------------------------------------------- /hw/first homework/protikha/ass-1.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /L22-Sending-mail.php: -------------------------------------------------------------------------------- 1 | 18 | 19 |
20 | 21 |
-------------------------------------------------------------------------------- /session/login.php: -------------------------------------------------------------------------------- 1 | 14 |

Login Form

15 |
16 | 17 |

18 | 19 |

20 | 21 |
-------------------------------------------------------------------------------- /L18-2-methods.php: -------------------------------------------------------------------------------- 1 | 9 | 10 |
11 | 12 | 13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /hw/first homework/AIMAN PHP Homework 1/L2_calculator.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /L3-Data_types.php: -------------------------------------------------------------------------------- 1 | "; 4 | var_dump(123); 5 | echo "
"; 6 | var_dump(123.123); 7 | echo "
"; 8 | var_dump(true); 9 | echo "
"; 10 | var_dump([1, 2, 3]); 11 | echo "
"; 12 | var_dump(null); 13 | echo "
"; 14 | class students { 15 | public $name = "Protikkha"; 16 | private $age = 21; 17 | protected $roll = 123; 18 | 19 | public function herAge () { 20 | return $this->age; 21 | } 22 | } 23 | 24 | class childOfStudent extends students { 25 | public function herRoll () { 26 | return $this->roll; 27 | } 28 | } 29 | $student = new students; 30 | var_dump($student); 31 | 32 | // resource 33 | ?> -------------------------------------------------------------------------------- /hw/first homework/protikha/ass-2.php: -------------------------------------------------------------------------------- 1 | "; 6 | 7 | $ss = "Mujhaid"; 8 | $ss .= " Boyati"; 9 | 10 | echo $ss; 11 | 12 | // Trimming strings 13 | $str = " Hello World "; 14 | echo "
" . trim($str) . "
"; 15 | 16 | // Removing slashes and other harmful characters 17 | $str = ""; 18 | echo htmlspecialchars(stripslashes($str)); 19 | 20 | // String functions 21 | echo "
" . strlen($fname) . "
"; 22 | echo str_word_count($fname) . "
"; 23 | echo strrev($fname) . "
"; 24 | echo strpos($fname, "t") . "
"; 25 | echo str_replace("Protikkha", "Protikkha Tanwi", $fname) . "
"; 26 | // substr 27 | echo substr($fname, 0, 4) . "
"; 28 | // str_shuffle 29 | echo str_shuffle($fname) . "
"; 30 | 31 | ?> -------------------------------------------------------------------------------- /L7-operators.php: -------------------------------------------------------------------------------- 1 | "; 28 | 29 | // Logical operators 30 | /** 31 | * && 32 | * || 33 | * and 34 | * or 35 | * ! 36 | */ 37 | 38 | // Comparisons 39 | /** 40 | * == 41 | * === 42 | * != 43 | * !== 44 | * > 45 | * < 46 | * >= 47 | * <= 48 | */ 49 | 50 | // Operator precedence 51 | /** 52 | * () 53 | * ** 54 | * * / % 55 | * + - 56 | * = += -= *= /= 57 | * and or 58 | * && || 59 | * == === != !== > < >= <= 60 | */ 61 | 62 | echo (2 + 3)**2 * 2; 63 | ?> -------------------------------------------------------------------------------- /L8-Mathematical_functions.php: -------------------------------------------------------------------------------- 1 | "; 25 | echo sqrt(100)."
"; 26 | echo pow(2, 3)."
"; 27 | 28 | echo exp(5)."
"; 29 | echo log(10)."
"; 30 | echo log10(100)."
"; 31 | echo sin(90)."
"; 32 | echo cos(90)."
"; 33 | echo tan(45)."
"; 34 | echo asin(1)."
"; 35 | echo acos(1)."
"; 36 | echo atan(1)."
"; 37 | 38 | echo rand(100000, 999999)."
"; 39 | echo min(0, 150, 30, 20, -8, -200)."
"; 40 | echo max(0, 150, 30, 20, -8, -200)."
"; 41 | echo round(0.60)."
"; 42 | echo ceil(0.10)."
"; 43 | echo floor(0.90)."
"; 44 | ?> -------------------------------------------------------------------------------- /L16-regular-expression.php: -------------------------------------------------------------------------------- 1 | "; 5 | echo preg_match("/world/", $str) . "
"; 6 | echo preg_match("/world/i", $str) . "
"; // i means case insensitive 7 | echo preg_match("/^Hello/", $str) . "
"; // ^ means start 8 | echo preg_match("/World$/", $str) . "
"; // $ means end 9 | echo preg_match("/^Hello World$/", $str) . "
"; // ^ means start and $ means end 10 | echo preg_match("/^Hello World$/i", $str) . "
"; // ^ means start and $ means end 11 | echo preg_match("/^Hello W\w+$/i", $str) . "
"; // \w+ means one or more word characters 12 | echo preg_match("/^Hello W\w{1,5}$/i", $str) . "
"; // \w{1,5} means one to five word characters 13 | // \d means one digit 14 | // example: \d{1,5} means one to five digits 15 | // \s means one whitespace 16 | // example: \s{1,5} means one to five whitespaces 17 | // \b means word boundary 18 | // example: \bHello\b means Hello word boundary 19 | // /^[A-Za-z]*$/ -------------------------------------------------------------------------------- /L31-opp-class.php: -------------------------------------------------------------------------------- 1 | myName." and I live in ".$this->myCity; 10 | } 11 | 12 | public function __construct($msg) { 13 | echo $msg."
"; 14 | } 15 | 16 | public function __destruct() { 17 | echo "This is a destructor function"; 18 | } 19 | } 20 | 21 | // instantiate the class | create object 22 | $myObj = new myInfo("Hello World"); 23 | $myObj->myName = "Asif"; 24 | echo $myObj->myDetails(); 25 | echo "
"; 26 | 27 | // inheritance 28 | class myChildInfo extends myInfo { 29 | public $myChildName = "Asifa Amrin"; 30 | 31 | public function myChildDetails() { 32 | return "My elder child name is ".$this->myChildName." and she lives in ".$this->myCity; 33 | } 34 | 35 | public function __construct() { 36 | return ; 37 | } 38 | 39 | public function __destruct() { 40 | return ; 41 | } 42 | } 43 | 44 | $myChildObj = new myChildInfo; 45 | echo $myChildObj->myChildDetails(); 46 | echo "
"; 47 | ?> -------------------------------------------------------------------------------- /L20-file-upload.php: -------------------------------------------------------------------------------- 1 | Please choose a file"; 12 | }elseif(!in_array($fileExt, $allowed)){ 13 | $msg = "Please choose a valid file"; 14 | }elseif($fileSize > 2000000){ 15 | $msg = "File size is too large"; 16 | }else{ 17 | $newFileName = uniqid('IMG-', false).'.'.$fileExt; 18 | $uploadPath = 'uploads/'.$newFileName; 19 | $move = move_uploaded_file($fileTmpName, $uploadPath); 20 | if($move){ 21 | $msg = "File uploaded successfully"; 22 | }else{ 23 | $msg = "File upload failed"; 24 | } 25 | } 26 | } 27 | ?> 28 | 29 |
30 | 31 | 32 |
33 | -------------------------------------------------------------------------------- /L18-1-superglobals.php: -------------------------------------------------------------------------------- 1 | "; 11 | 12 | // $_SERVER 13 | echo $_SERVER['PHP_SELF']."
"; 14 | echo $_SERVER['SERVER_NAME']."
"; 15 | echo $_SERVER['HTTP_HOST']."
"; 16 | echo $_SERVER['HTTP_USER_AGENT']."
"; 17 | echo $_SERVER['SCRIPT_NAME']."
"; 18 | // get user ip address 19 | echo $_SERVER['REMOTE_ADDR']."
"; 20 | // get server ip address 21 | echo $_SERVER['SERVER_ADDR']."
"; 22 | echo "
";
23 |     print_r($_SERVER);
24 |     echo "
"; 25 | 26 | // $_REQUEST 27 | echo $_REQUEST['name']."
"; 28 | echo $_REQUEST['email']."
"; 29 | 30 | // $_POST 31 | echo $_POST['name']."
"; 32 | echo $_POST['email']."
"; 33 | 34 | // $_GET 35 | echo $_GET['name']."
"; 36 | echo $_GET['email']."
"; 37 | 38 | // $_FILES 39 | echo $_FILES['file']['name']."
"; 40 | echo $_FILES['file']['type']."
"; 41 | echo $_FILES['file']['tmp_name']."
"; 42 | echo $_FILES['file']['error']."
"; 43 | echo $_FILES['file']['size']."
"; 44 | 45 | // $_ENV 46 | echo $_ENV['USER']."
"; 47 | 48 | // $_COOKIE 49 | echo $_COOKIE['user']."
"; 50 | 51 | // $_SESSION 52 | session_start(); 53 | $_SESSION['user'] = "John Doe"; 54 | echo $_SESSION['user']."
"; 55 | ?> -------------------------------------------------------------------------------- /L25- Date-Time.php: -------------------------------------------------------------------------------- 1 | "; 4 | echo date('d-M-Y H:i:s A l')."
"; 5 | echo date('d-F-Y h:i:s a l')."
"; 6 | 7 | // mktime(hour, minute, second, month, day, year) 8 | $timestamp = mktime(10, 30, 45, 9, 10, 2024); 9 | echo date('d-M-Y h:i:s a l', $timestamp)."
"; 10 | 11 | // strtotime(time, now) 12 | $timestamp = strtotime('tomorrow'); 13 | echo date('d-M-Y h:i:s a l', $timestamp)."
"; 14 | $timestamp = strtotime('next Friday'); 15 | echo date('d-M-Y h:i:s a l', $timestamp)."
"; 16 | $timestamp = strtotime('+5 years 4 months +2 days'); 17 | echo date('d-M-Y h:i:s a l', $timestamp)."
"; 18 | 19 | // next 7 friday 20 | $startDay = strtotime('next Friday'); 21 | $endDay = strtotime('+6 weeks', $startDay); 22 | while($startDay <= $endDay){ 23 | echo date('d-M-Y l', $startDay)."
"; 24 | $startDay = strtotime('+1 week', $startDay); 25 | } 26 | 27 | // DateTime 28 | $date = new DateTime(); 29 | echo $date->format('d-M-Y h:i:s a l')."
"; 30 | $date = new DateTime('2020-12-25'); 31 | echo $date->format('d-M-Y h:i:s a l')."
"; 32 | $date = new DateTime('2020-12-25 10:30:45'); 33 | echo $date->format('d-M-Y h:i:s a l')."
"; 34 | 35 | $date1 = new DateTime("2020-12-25"); 36 | $date2 = new DateTime("2024-9-10"); 37 | $diff = $date1->diff($date2); 38 | echo $diff->format('%y years %m months %d days')."
"; 39 | ?> -------------------------------------------------------------------------------- /L32-oop-part-2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /L27-File-system.php: -------------------------------------------------------------------------------- 1 | "; 5 | 6 | // dirname() 7 | echo dirname($path)."
"; 8 | 9 | // copy() 10 | copy('test.txt', 'test2.txt'); 11 | 12 | // file() 13 | $file = file('test.txt'); 14 | echo "
";
15 |     print_r($file);
16 |     echo "
"; 17 | 18 | // file_exists() 19 | if(file_exists('test.txt')){ 20 | echo "File exists
"; 21 | } 22 | 23 | // file_get_contents() 24 | $data = file_get_contents('test.txt'); 25 | echo $data."
"; 26 | 27 | // file_put_contents() 28 | file_put_contents('test.txt', "Hello World\nHello PHP\nHello Laravel"); 29 | 30 | // filesize() 31 | echo filesize('test.txt')."
"; 32 | 33 | // filetype() 34 | echo filetype('test.txt')."
"; 35 | 36 | // is_dir() 37 | if(is_dir('./uploads')){ 38 | echo "It is a directory
"; 39 | } 40 | 41 | // is_file() 42 | if(is_file('test.txt')){ 43 | echo "It is a file
"; 44 | } 45 | 46 | // link() 47 | if(is_file('test-link.txt')){ 48 | echo "File already exits
"; 49 | }else{ 50 | link('test.txt', 'test-link.txt'); 51 | echo "New File created
"; 52 | } 53 | 54 | // unlink() 55 | if(is_file('test-link.txt')){ 56 | unlink('test-link.txt'); 57 | echo "File deleted
"; 58 | } 59 | 60 | // mkdir() 61 | mkdir("test-uploads"); 62 | 63 | // rmdir() 64 | rmdir("test-uploads"); 65 | 66 | // move_uploaded_file() 67 | 68 | // pathinfo() 69 | $path_parts = pathinfo($path); 70 | echo "
";
71 |     print_r($path_parts);
72 |     echo "
"; 73 | 74 | // extension() 75 | echo pathinfo($path, PATHINFO_EXTENSION)."
"; 76 | 77 | 78 | ?> -------------------------------------------------------------------------------- /L9-Control_Statements.php: -------------------------------------------------------------------------------- 1 | "; 12 | }elseif($express[rand(0, (count($express) - 1))] == "Motamuty"){ 13 | $_SESSION['lav'] += 5; 14 | echo "Motamuty Lav Hoise. Total Lav:".$_SESSION['lav']."
"; 15 | }else{ 16 | $_SESSION['lav'] -= 10; 17 | echo "Lav Nai :(. Total Lav: ".$_SESSION['lav']."
"; 18 | } 19 | $_SESSION['total']++; 20 | }else{ 21 | echo "Total Lav: ".$_SESSION['lav']."
"; 22 | session_unset(); 23 | } 24 | 25 | // switch statement 26 | 27 | $day = "Friday"; 28 | 29 | switch($day){ 30 | case "Saturday": 31 | echo "Today is Saturday"; 32 | break; 33 | case "Sunday": 34 | echo "Today is Sunday"; 35 | break; 36 | case "Monday": 37 | echo "Today is Monday"; 38 | break; 39 | case "Tuesday": 40 | echo "Today is Tuesday"; 41 | break; 42 | case "Wednesday": 43 | echo "Today is Wednesday"; 44 | break; 45 | case "Thursday": 46 | echo "Today is Thursday"; 47 | break; 48 | case "Friday": 49 | echo "Today is Friday"; 50 | break; 51 | default: 52 | echo "Invalid Day"; 53 | } 54 | 55 | // ternary operator 56 | 57 | if(2 == 2) { 58 | echo "True"; 59 | }else{ 60 | echo "False"; 61 | } 62 | 63 | (2 == 6) ? "True" : "False"; 64 | 65 | echo $protikha ?? "No value"; 66 | ?> -------------------------------------------------------------------------------- /L29-crud.php: -------------------------------------------------------------------------------- 1 | query("DELETE FROM `students` WHERE `id` = '$id'"); 7 | if($delete){ 8 | echo ""; 9 | }else{ 10 | echo ""; 11 | } 12 | } 13 | 14 | if (isset($_POST['addStudent'])) { 15 | $yname = $_POST['yname']; 16 | $insert = $conn->query("INSERT INTO `students` (`name`) VALUES ('$yname')"); 17 | if ($insert) { 18 | echo ""; 19 | } else { 20 | echo ""; 21 | } 22 | } 23 | 24 | if(isset($_POST['editStudent'])){ 25 | $ename = $_POST['ename']; 26 | $id = $_GET['edit']; 27 | $update = $conn->query("UPDATE `students` SET `name` = '$ename' WHERE `id` = '$id'"); 28 | if($update){ 29 | echo ""; 30 | }else{ 31 | echo ""; 32 | } 33 | } 34 | 35 | $select = $conn->query("SELECT * FROM `students`"); 36 | 37 | if (isset($_GET['edit'])) { 38 | $id = $_GET['edit']; 39 | $singleStudentInfoQuery = $conn->query("SELECT * FROM `students` WHERE `id` = '$id'"); 40 | $singleStudentInfo = $singleStudentInfoQuery->fetch_assoc(); 41 | } 42 | ?> 43 | 44 |
45 | 46 | 47 |
48 | 49 |
50 | 51 | 52 |
53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | fetch_assoc()) { ?> 62 | 63 | 66 | 69 | 73 | 74 | 75 |
IDNameAction
64 | 65 | 67 | 68 | 70 | 71 | 72 |
-------------------------------------------------------------------------------- /L12-Array-functions.php: -------------------------------------------------------------------------------- 1 | "; 8 | if(is_array($arr)){ 9 | foreach($arr as $city){ 10 | echo $city . "
"; 11 | } 12 | }else{ 13 | echo "We dont have any data"; 14 | } 15 | 16 | // in_array() 17 | var_dump(in_array('Khulna', $arr)); 18 | 19 | // array_merge() 20 | $arr1 = array('Dhaka', 'Noyakhali', 'Chatogram', "Bogura"); 21 | 22 | $merged_arr = array_merge($arr, $arr1); 23 | echo "
";
 24 |     print_r($merged_arr);
 25 |     echo "
"; 26 | 27 | // array_keys() 28 | $studentInfo = ["name" => "Rakib", "age" => 23, "isStudent" => true, "cgpa" => 3.5]; 29 | $keys = array_keys($studentInfo); 30 | echo "
";
 31 |     print_r($keys);
 32 |     echo "
"; 33 | 34 | // array_key_exists() 35 | var_dump(array_key_exists('city', $studentInfo)); 36 | 37 | // array_shift() 38 | array_shift($merged_arr); 39 | echo "
";
 40 |     print_r($merged_arr);
 41 |     echo "
"; 42 | 43 | // array_unshift() 44 | array_unshift($merged_arr, 'Kuyakata', 'Coxs Bazar'); 45 | echo "
";
 46 |     print_r($merged_arr);
 47 |     echo "
"; 48 | 49 | // array_push() 50 | array_push($merged_arr, 'Kuyakata', 'Coxs Bazar'); 51 | echo "
";
 52 |     print_r($merged_arr);
 53 |     echo "
"; 54 | 55 | // array_pop() 56 | array_pop($merged_arr); 57 | echo "
";
 58 |     print_r($merged_arr);
 59 |     echo "
"; 60 | 61 | // array_values() 62 | $values = array_values($studentInfo); 63 | echo "
";
 64 |     print_r($values);
 65 |     echo "
"; 66 | 67 | // array_map() 68 | function showCity($city){ 69 | if(strlen($city) <= 6){ 70 | return $city; 71 | } 72 | } 73 | $cityList = array_map('showCity', $merged_arr); 74 | echo "
";
 75 |     print_r($cityList);
 76 |     echo "
"; 77 | 78 | // array_unique() 79 | $uniqueCities = array_unique($merged_arr); 80 | echo "
";
 81 |     print_r($uniqueCities);
 82 |     echo "
"; 83 | 84 | // array_slice() 85 | $slicedCities = array_slice($uniqueCities, 2, 3); 86 | echo "
";
 87 |     print_r($slicedCities);
 88 |     echo "
"; 89 | 90 | // array_diff() 91 | $diff = array_diff($arr1, $arr); 92 | echo "
";
 93 |     print_r($diff);
 94 |     echo "
"; 95 | 96 | // array_search() 97 | var_dump(array_search('Brammonbaria', $arr1)); 98 | 99 | // array_reverse() 100 | $reversedCities = array_reverse($uniqueCities); 101 | echo "
";
102 |     print_r($reversedCities);
103 |     echo "
"; 104 | 105 | -------------------------------------------------------------------------------- /L30-session.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM `users` WHERE `user_name` = '$ruserName'"); 10 | if($check_username->num_rows > 0){ 11 | echo ""; 12 | }else{ 13 | $rpassword = md5($rpassword); 14 | $insert = $conn->query("INSERT INTO `users` (`user_name`, `password`) VALUES ('$ruserName', '$rpassword')"); 15 | if($insert){ 16 | echo ""; 17 | }else{ 18 | echo ""; 19 | } 20 | } 21 | } 22 | 23 | if(isset($_POST['login'])){ 24 | $userName = $_POST['userName']; 25 | $password = $_POST['password']; 26 | $password = md5($password); 27 | 28 | $check_user = $conn->query("SELECT * FROM `users` WHERE `user_name` = '$userName' AND `password` = '$password'"); 29 | 30 | if ($check_user->num_rows == 1) { 31 | $_SESSION['user'] = $userName; 32 | echo ""; 33 | }else{ 34 | echo ""; 35 | } 36 | } 37 | 38 | if(isset($_GET['logout'])){ 39 | session_unset(); 40 | echo ""; 41 | } 42 | ?> 43 | 44 | 45 | 46 | 47 | 48 | Document 49 | 50 | 51 | 52 | 53 | 54 | 64 | 74 | 75 |
55 |

Login Form

56 |
57 | 58 |

59 | 60 |

61 | 62 |
63 |
65 |

Registration Form

66 |
67 | 68 |

69 | 70 |

71 | 72 |
73 |
76 | 77 |

Welcome

78 | Logout 79 | 80 | 81 | -------------------------------------------------------------------------------- /L11-Arrays.php: -------------------------------------------------------------------------------- 1 | "; 7 | print_r($arr); 8 | echo ""; 9 | 10 | // associative array 11 | $arr = ["name" => "Rakib", "age" => 23, "isStudent" => true, "cgpa" => 3.5]; 12 | echo $arr["name"]; 13 | echo "
";
 14 |     print_r($arr);
 15 |     echo "
"; 16 | 17 | // multidimensional array 18 | $arr = [ 19 | "student-1" => ["name" => "Rakib", "age" => 23, "isStudent" => true, "cgpa" => 3.5], 20 | "student-2" =>["name" => "Sakib", "age" => 24, "isStudent" => true, "cgpa" => 3.4], 21 | "student-3" =>["name" => "Mukib", "age" => 43, "isStudent" => true, "cgpa" => 3.3], 22 | "student-4" =>["name" => "Nakib", "age" => 53, "isStudent" => true, "cgpa" => 3.2], 23 | ]; 24 | echo $arr["student-1"]["name"]; 25 | echo "
";
 26 |     print_r($arr);
 27 |     echo "
"; 28 | 29 | $studentNames = [ 30 | ["Abul", "Babul", "Kabul"], 31 | ["Rakib", "Sakib", "Mukib"], 32 | ["Nakib", "Dakib", "Bakib"], 33 | ]; 34 | echo "
";
 35 |     print_r($studentNames);
 36 |     echo "
"; 37 | 38 | $studentNames = ["Abul", "Babul", "Kabul", "Rakib", "Sakib", "Mukib", "Nakib", "Dakib", "Bakib"]; 39 | for($i = 0; $i < count($studentNames); $i++){ 40 | $x; 41 | if($i == count($studentNames) - 1){ 42 | $x = "."; 43 | } else if($i == count($studentNames) - 2){ 44 | $x = " and "; 45 | } else { 46 | $x = ", "; 47 | } 48 | echo $studentNames[$i] . $x; 49 | } 50 | 51 | echo "
"; 52 | 53 | foreach($studentNames as $i => $name){ 54 | $x; 55 | if($i == count($studentNames) - 1){ 56 | $x = "."; 57 | } else if($i == count($studentNames) - 2){ 58 | $x = " and "; 59 | } else { 60 | $x = ", "; 61 | } 62 | echo $name . $x; 63 | } 64 | 65 | echo "
"; 66 | 67 | $studentInfo = [ 68 | "name" => "Protikkha", 69 | "age" => 23, 70 | "isStudent" => true, 71 | "cgpa" => 3.5, 72 | "subjects" => "CSE", 73 | ]; 74 | 75 | foreach($studentInfo as $key => $value){ 76 | echo ucfirst($key) . " : " . $value . "
"; 77 | } 78 | 79 | echo "
"; 80 | 81 | // multidimensional array 82 | $students = [ 83 | ["Rakib", 23, true, 3.5], 84 | ["Sakib", 24, true, 3.4], 85 | ["Mukib", 43, true, 3.3], 86 | ["Nakib", 53, true, 3.2], 87 | ]; 88 | 89 | for ($i=0; $i < count($students); $i++) { 90 | for ($j=0; $j < count($students[$i]); $j++) { 91 | echo $students[$i][$j] . " "; 92 | } 93 | echo "
"; 94 | } 95 | 96 | echo "
"; 97 | 98 | $students = [ 99 | ["name" => "Rakib", "age" => 23, "isStudent" => true, "cgpa" => 3.5], 100 | ["name" => "Sakib", "age" => 24, "isStudent" => true, "cgpa" => 3.4], 101 | ["name" => "Mukib", "age" => 43, "isStudent" => true, "cgpa" => 3.3], 102 | ["name" => "Nakib", "age" => 53, "isStudent" => true, "cgpa" => 3.2], 103 | ]; 104 | 105 | foreach($students as $student){ 106 | foreach($student as $key => $value){ 107 | echo ucfirst($key) . " : " . $value . "
"; 108 | } 109 | echo "
"; 110 | } 111 | 112 | ?> -------------------------------------------------------------------------------- /L33-oop-part-3.php: -------------------------------------------------------------------------------- 1 | 2 | "; 8 | } 9 | 10 | public function __set($name, $value) { 11 | $this->setProperties[$name] = $value; 12 | echo $this->setProperties[$name]."
"; 13 | } 14 | 15 | public function __isset($name) { 16 | if(isset($this->setProperties[$name]) || isset($this->$name)) { 17 | echo "Property $name is set
"; 18 | } else { 19 | echo "Property $name is not set
"; 20 | } 21 | } 22 | 23 | public function __unset($name) { 24 | echo "Unsetting is not allowed
"; 25 | } 26 | 27 | // __call() method is triggered when invoking inaccessible methods in an object context. 28 | public function __call($name, $arguments) { 29 | echo "You are trying to access non-existing or private method $name
"; 30 | } 31 | 32 | // __callStatic() is triggered when invoking inaccessible methods in a static context. 33 | public static function __callStatic($name, $arguments) { 34 | echo "You are trying to access non-existing or private static method $name
"; 35 | } 36 | 37 | // __sleep() method is called when the object is serialized. 38 | public function __sleep() { 39 | return ["status"]; 40 | } 41 | 42 | // __wakeup() method is called when the object is unserialized. 43 | public function __wakeup() { 44 | echo "Wakeup method is called
"; 45 | } 46 | 47 | // __serialize() method is called when the object is serialized. 48 | public function __serialize() { 49 | return ["setProperties" => $this->status, "status" => $this->status]; 50 | } 51 | 52 | // __unserialize() method is called when the object is unserialized. 53 | public function __unserialize(array $data) { 54 | $this->setProperties = $data["setProperties"]; 55 | $this->status = $data["status"]; 56 | } 57 | 58 | // __toString() method allows a class to decide how it will react when it is treated like a string. 59 | public function __toString() { 60 | return "This is a myClass object
"; 61 | } 62 | 63 | // __invoke() method is called when a script tries to call an object as a function. 64 | 65 | public function __invoke() { 66 | return "Object is being called as a function
"; 67 | } 68 | 69 | // __set_state() is called for classes exported by var_export() when var_export() is called with the __set_state() magic method. 70 | public static function __set_state(array $properties) { 71 | $obj = new myClass(); 72 | $obj->setProperties = $properties["setProperties"]; 73 | $obj->status = $properties["status"]; 74 | return $obj; 75 | } 76 | 77 | // __clone() method is called when an object is cloned. 78 | public function __clone() { 79 | echo "Object is being cloned
"; 80 | } 81 | 82 | // __debugInfo() method is called by var_dump() when dumping an object to get the properties that should be shown. 83 | public function __debugInfo() { 84 | return ["setProperties" => $this->setProperties, "status" => $this->status]; 85 | } 86 | } 87 | 88 | $obj = new myClass(); 89 | echo $obj->city; 90 | $obj->city = "Dhaka"; 91 | isset($obj->age); 92 | unset($obj->city); 93 | $obj->myMethod(); 94 | myClass::myStaticMethod(); 95 | echo "
";
 96 |     print_r(serialize($obj));
 97 |     echo "
"; 98 | echo unserialize(serialize($obj))->status; 99 | echo "
"; 100 | echo $obj; 101 | echo $obj(); 102 | $obj->setProperties = ["name" => "Aiman", "age" => 22]; 103 | 104 | $exportedObj = var_export($obj, true); 105 | eval('$newObj = '.$exportedObj.';'); 106 | echo "
";
107 |     print_r($newObj);
108 |     echo "
"; 109 | 110 | $clonedObj = clone $obj; 111 | echo "
";
112 |     print_r($obj);
113 |     echo "
"; 114 | ?> -------------------------------------------------------------------------------- /hw/protikha6-06-2024/homework.php: -------------------------------------------------------------------------------- 1 | array_map('strtolower', $array), 39 | 'uppercase' => array_map('strtoupper', $array), 40 | ]; 41 | } 42 | 43 | // viii. Get unique values 44 | function getUniqueValues($array) { 45 | return array_unique($array); 46 | } 47 | 48 | // ix. Remove duplicate values 49 | function removeDuplicates($array) { 50 | return array_values(array_unique($array)); 51 | } 52 | 53 | // x. Check if email address is unique 54 | function isEmailUnique($array, $email) { 55 | return !in_array($email, $array); 56 | } 57 | 58 | // xi. Check unique username 59 | function isUsernameUnique($array, $username) { 60 | return !in_array($username, $array); 61 | } 62 | 63 | // xii. Merge 2 comma separated lists with unique value only 64 | function mergeCommaSeparatedLists($list1, $list2) { 65 | $array1 = explode(',', $list1); 66 | $array2 = explode(',', $list2); 67 | return implode(',', array_unique(array_merge($array1, $array2))); 68 | } 69 | 70 | // xiii. Difference between 2 multi-dimensional arrays 71 | function arrayDiffMulti($array1, $array2) { 72 | return array_diff_assoc($array1, $array2); 73 | } 74 | 75 | // xiv. Check if all values are string or not 76 | function areAllValuesString($array) { 77 | foreach ($array as $value) { 78 | if (!is_string($value)) { 79 | return false; 80 | } 81 | } 82 | return true; 83 | } 84 | 85 | // xv. Union of 2 arrays 86 | function unionArrays($array1, $array2) { 87 | return array_unique(array_merge($array1, $array2)); 88 | } 89 | 90 | // xvi. Filter out array data with some specific keys 91 | function filterArrayByKeys($array, $keys) { 92 | return array_intersect_key($array, array_flip($keys)); 93 | } 94 | 95 | // xvii. Filter a multi-dimensional array 96 | function filterMultiDimensionalArray($array, $callback) { 97 | return array_filter($array, $callback); 98 | } 99 | 100 | // xviii. Remove all white spaces from an array 101 | function removeWhiteSpaces($array) { 102 | return array_map('trim', $array); 103 | } 104 | 105 | // xix. Combine 2 arrays and use one array data as keys and others as values 106 | function combineArraysAsKeyValue($keys, $values) { 107 | return array_combine($keys, $values); 108 | } 109 | 110 | // xx. Convert string to array 111 | function stringToArray($string, $delimiter = ',') { 112 | return explode($delimiter, $string); 113 | } 114 | 115 | // Example usage: 116 | 117 | // i. 118 | echo "
";
119 | echo findMax([1, 2, 3, 4, 5]); // 5
120 | 
121 | // ii.
122 | echo findSecondMax([1, 2, 3, 4, 5]); // 4
123 | 
124 | // iii.
125 | print_r(sortArray([5, 3, 1, 4, 2]));
126 | 
127 | // iv.
128 | echo calculateAverage([1, 2, 3, 4, 5]); // 3
129 | 
130 | // v.
131 | print_r(mergeArrays([1, 2], ['a', 'b']));
132 | 
133 | // vi.
134 | echo searchData([1, 2, 3, 4, 5], 3); // 1 (true)
135 | 
136 | // vii.
137 | print_r(showArrayCase(['Apple', 'Banana', 'Cherry']));
138 | 
139 | // viii.
140 | print_r(getUniqueValues([1, 1, 2, 2, 3, 3]));
141 | 
142 | // ix.
143 | print_r(removeDuplicates([1, 1, 2, 2, 3, 3]));
144 | 
145 | // x.
146 | echo isEmailUnique(['test@example.com'], 'new@example.com'); // 1 (true)
147 | 
148 | // xi.
149 | echo isUsernameUnique(['user1', 'user2'], 'user3'); // 1 (true)
150 | 
151 | // xii.
152 | echo mergeCommaSeparatedLists('a,b,c', 'b,c,d'); // a,b,c,d
153 | 
154 | // xiii.
155 | print_r(arrayDiffMulti(['a' => 1, 'b' => 2], ['a' => 1, 'b' => 3]));
156 | 
157 | // xiv.
158 | echo areAllValuesString(['a', 'b', 'c']); // 1 (true)
159 | 
160 | // xv.
161 | print_r(unionArrays([1, 2], [2, 3]));
162 | 
163 | // xvi.
164 | print_r(filterArrayByKeys(['a' => 1, 'b' => 2, 'c' => 3], ['a', 'c']));
165 | 
166 | // xvii.
167 | print_r(filterMultiDimensionalArray([['name' => 'John'], ['name' => 'Jane']], function($item) {
168 |     return $item['name'] === 'John';
169 | }));
170 | 
171 | // xviii.
172 | print_r(removeWhiteSpaces([' a ', ' b ', ' c ']));
173 | 
174 | // xix.
175 | print_r(combineArraysAsKeyValue(['a', 'b'], [1, 2]));
176 | 
177 | // xx.
178 | print_r(stringToArray('a,b,c'));
179 | echo "
"; 180 | ?> 181 | -------------------------------------------------------------------------------- /L17-problem-solving.php: -------------------------------------------------------------------------------- 1 | $max){ 8 | $max = $arr[$i]; 9 | } 10 | } 11 | echo "Maximum number is: ".$max."
"; 12 | 13 | echo max($arr)."
"; 14 | 15 | // Find 2nd max number from an array 16 | $arr = [5, 81, 34, 96, 15, 62, 74, 23, 42]; 17 | $max = $arr[0]; 18 | $secondMax = $arr[0]; 19 | for($i = 1; $i < count($arr); $i++){ 20 | if($arr[$i] > $max){ 21 | $secondMax = $max; 22 | $max = $arr[$i]; 23 | }else if($arr[$i] > $secondMax && $arr[$i] < $max){ 24 | $secondMax = $arr[$i]; 25 | } 26 | } 27 | 28 | echo "Second Maximum number is: ".$secondMax."
"; 29 | 30 | // Sort array from min to max 31 | $arr = [5, 81, 34, 96, 15, 62, 74, 23, 42]; 32 | sort($arr); 33 | echo "
";
 34 |     print_r($arr);
 35 |     echo "
"; 36 | 37 | // Calculate average number of an array 38 | $arr = [5, 81, 34, 96, 15, 62, 74, 23, 42]; 39 | $sum = 0; 40 | for($i = 0; $i < count($arr); $i++){ 41 | $sum += $arr[$i]; 42 | } 43 | $average = $sum / count($arr); 44 | echo "Average number is: ".$average."
"; 45 | 46 | // Merging 2 different types of array together 47 | $arr1 = [5, 81, 34, 96, 15, 62, 74, 23, 42]; 48 | $arr2 = ["Dhaka", "Barishal", "Bogura", "Noyakhali", "Chatogram", "Bogura"]; 49 | $merged_arr = array_merge($arr1, $arr2); 50 | echo "
";
 51 |     print_r($merged_arr);
 52 |     echo "
"; 53 | 54 | // Search data from an array 55 | $arr = ["Dhaka", "Barishal", "Bogura", "Noyakhali", "Chatogram", "Bogura"]; 56 | $search = "Bogura"; 57 | $found = false; 58 | for($i = 0; $i < count($arr); $i++){ 59 | if($arr[$i] == $search){ 60 | $found = true; 61 | break; 62 | } 63 | } 64 | if($found){ 65 | echo "Data found"; 66 | }else{ 67 | echo "Data not found"; 68 | } 69 | 70 | echo "
"; 71 | 72 | // Show array data in lowercase and uppercase 73 | $arr = ["Dhaka", "Barishal", "Bogura", "Noyakhali", "Chatogram", "Bogura"]; 74 | for($i = 0; $i < count($arr); $i++){ 75 | echo strtoupper($arr[$i])."
"; 76 | } 77 | 78 | echo "
"; 79 | 80 | for($i = 0; $i < count($arr); $i++){ 81 | echo strtolower($arr[$i])."
"; 82 | } 83 | 84 | // Get unique values 85 | $arr = ["Dhaka", "Barishal", "Bogura", "Noyakhali", "Chattogram", "Bogura", "Dhaka", "Barishal"]; 86 | $unique = []; 87 | for($i = 0; $i < count($arr); $i++){ 88 | if(!in_array($arr[$i], $unique)){ 89 | array_push($unique, $arr[$i]); 90 | } 91 | } 92 | 93 | echo "
";
 94 |     print_r($unique);
 95 |     echo "
"; 96 | 97 | // Check if email address is unique 98 | $emails = ["abdul@gmail.com", "kuddus@gmail.com", "kurban@gmail.com", "bablu@gmail.com"]; 99 | $email = "kuddus@gmail.com"; 100 | 101 | if(in_array($email, $emails)){ 102 | echo "Email already exists"; 103 | }else{ 104 | echo "Email is unique"; 105 | } 106 | 107 | // Merge 2 comma separated lists with unique value only 108 | $list1 = "Dhaka, Bogura, Noyakhali, Chattogram, Bogura, Dhaka, Barishal, Jhinaidah"; 109 | $list2 = "Dhaka, Barishal, Bogura, Noyakhali, Chattogram, Bogura, Dhaka, Barishal, Kustia"; 110 | $arr1 = explode(", ", $list1); 111 | $arr2 = explode(", ", $list2); 112 | $merged_arr = array_merge($arr1, $arr2); 113 | $unique = []; 114 | for($i = 0; $i < count($merged_arr); $i++){ 115 | if(!in_array($merged_arr[$i], $unique)){ 116 | array_push($unique, $merged_arr[$i]); 117 | } 118 | } 119 | 120 | echo "
";
121 |     print_r($unique);
122 |     echo "
"; 123 | 124 | $text = "Ami vaat Khai"; 125 | $arr = explode(" ", $text); 126 | echo "
";
127 |     print_r($arr);
128 |     echo "
"; 129 | 130 | // Difference between 2 multi-dimensional arrays 131 | $arr1 = [ 132 | ["name" => "Rakib", "age" => 23, "isStudent" => true, "cgpa" => 3.5], 133 | ["name" => "Sakib", "age" => 24, "isStudent" => true, "cgpa" => 3.6], 134 | ["name" => "Mukib", "age" => 25, "isStudent" => true, "cgpa" => 3.7], 135 | ]; 136 | 137 | $arr2 = [ 138 | ["name" => "Rakib", "age" => 23, "isStudent" => true, "cgpa" => 3.5], 139 | ["name" => "Sakib", "age" => 24, "isStudent" => true, "cgpa" => 3.6], 140 | ["name" => "Mukib", "age" => 25, "isStudent" => true, "cgpa" => 3.7], 141 | ["name" => "Nakib", "age" => 26, "isStudent" => true, "cgpa" => 3.8], 142 | ]; 143 | 144 | $diff = []; 145 | for($i = 0; $i < count($arr2); $i++){ 146 | if(!in_array($arr2[$i], $arr1)){ 147 | array_push($diff, $arr2[$i]); 148 | } 149 | } 150 | 151 | echo "
";
152 |     print_r($diff);
153 |     echo "
"; 154 | 155 | // Check if all values are string or not 156 | $arr = ["Dhaka", "Barishal", "Bogura", "Noyakhali", "Chattogram", "Bogura"]; 157 | $allString = true; 158 | for($i = 0; $i < count($arr); $i++){ 159 | if(!is_string($arr[$i])){ 160 | $allString = false; 161 | break; 162 | } 163 | } 164 | 165 | if($allString){ 166 | echo "All values are string"; 167 | }else{ 168 | echo "All values are not string"; 169 | } 170 | 171 | echo "
"; 172 | 173 | // Filter out array data with some specific keys 174 | $arr = [ 175 | ["name" => "Rakib", "age" => 23, "isStudent" => true, "cgpa" => 3.5], 176 | ["name" => "Sakib", "age" => 24, "isStudent" => true, "cgpa" => 3.6], 177 | ["name" => "Mukib", "age" => 25, "isStudent" => true, "cgpa" => 3.7], 178 | ]; 179 | 180 | $filtered = []; 181 | for($i = 0; $i < count($arr); $i++){ 182 | $filtered[$i]["name"] = $arr[$i]["name"]; 183 | $filtered[$i]["age"] = $arr[$i]["age"]; 184 | } 185 | echo "
";
186 |     print_r($filtered);
187 |     echo "
"; 188 | 189 | // Combine 2 array and use one array data as keys and others as values 190 | $arr1 = ["name", "age", "isStudent", "cgpa"]; 191 | $arr2 = ["Rakib", 23, true, 3.5]; 192 | $combined = []; 193 | for($i = 0; $i < count($arr1); $i++){ 194 | $combined[$arr1[$i]] = $arr2[$i]; 195 | } 196 | $combined["city"] = "Dhaka"; 197 | echo "
";
198 |     print_r($combined);
199 |     echo "
"; 200 | 201 | ?> -------------------------------------------------------------------------------- /L19-form-validation.php: -------------------------------------------------------------------------------- 1 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | Document 91 | 92 | 93 | 94 | 95 |
96 |
97 |
98 |

Sign-up form

99 |
100 |
101 | 102 |
103 |
104 |
105 | 106 |
107 |
108 |
109 | 110 |
111 |
112 |
rounded py-1"> 113 |
114 | 115 |
116 |
117 | 120 |
121 |
122 | 125 |
126 |
127 |
128 | 129 |
130 |
rounded py-1"> 131 |
132 | 133 |
134 |
135 | 138 |
139 |
140 | 143 |
144 |
145 | 148 |
149 |
150 |
151 | 152 |
153 |
154 | 160 |
161 | 162 |
163 |
164 |
165 | 166 |
167 |
168 |
169 |
170 |
171 | 172 | 173 | --------------------------------------------------------------------------------