Skip to content

Commit

Permalink
14-02-2023
Browse files Browse the repository at this point in the history
  • Loading branch information
farhadfoysal committed Feb 14, 2023
1 parent b1ac5b9 commit 9f88d41
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ArrayClass/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php


?>
59 changes: 59 additions & 0 deletions class/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

class player{
public $name = "null";
public $speed = 5;
public $running = false;

// function __construct($name){
// $this->name = $name;
// $this->speed = $s;
// $this->running = true;
// }

function __construct($name = "Farhad Name"){
$this->name = $name;
// $this->speed = $s;
$this->running = true;
}
function __destruct(){
echo "hello destruct <br>";
}

function set_name($name){
$this->name = $name;
}

function get_name(){
return $this->name;
}
function get_run(){
return $this->running = true;
}
function stopRun(){
return $this->running = false;
}
}

$p1 = new player("Farhad");

$p2 = new player("Foysal");

$p1->set_name("Farhad Foysal");.
$p2->set_name("Farhad MOni");

echo $p1->get_name()." <br>".$p2->get_name()."<br>".$p2->get_run()."<br>";

$p3 = new player("Moni");

echo $p3->name."<br>";

$p4 = new player("constractor_name");

echo $p4->name."<br>";

$p5 = new player("");



?>
10 changes: 10 additions & 0 deletions cookies/cookie.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php


$cat = $_COOKIE['category'];

echo $cat;



?>
5 changes: 5 additions & 0 deletions cookies/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

setcookie("category", "Books", time() + 86400, "/");

?>
36 changes: 36 additions & 0 deletions date/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

date_default_timezone_set("Asia/Dhaka");
$today=date("Y-m-d");
$time= date("h:i:s");


$dateef = strtotime($today);

$monthh = date('m', $dateef);
$yearr= date('Y', $dateef);

$mon = date('m', $dateef);
$yea= date('Y', $dateef);



$ran_id = rand(time(), 1000000000);
$referr = strtoupper(bin2hex(random_bytes(1)));

$d = date("l");
echo "today is $d <br>";
$d = date("d l");
echo "today is $d <br>";
$d = date("d D");
echo "today is $d <br>";
$d = date("l dS F Y");
echo "today is $d <br>";
$d = date("l dS F Y, g:i A");
echo "today is $d <br>";
$d = date("l dS F Y h:i:s A");
echo "today is $d <br>";



?>
66 changes: 66 additions & 0 deletions files/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

echo readfile("index.txt");
echo "<br>";
readfile("index.txt");

echo "<br>";

$fopen = fopen("index.txt", "r");

echo var_dump($fopen);

if(!$fopen){
die("unable to open this file. please enter valid filename");
}


// $content = fread($fopen, 70);

$content = fread($fopen, filesize("index.txt"));
fclose($fopen);

echo $content."<br>";

$fopen = fopen("index.txt", "r");
// echo fgets($fopen)."<br>";
// echo fgets($fopen)."<br>";
// echo fgets($fopen)."<br>";

// while($a=fgets($fopen)){
// echo $a."<br>";
// }

// while($a=fgetc($fopen)){
// echo $a." ";

// }


while($a=fgetc($fopen)){
echo $a." ";
if($a==".."){
break;
}
}
echo "<br>";

fclose($fopen);

$fopen = fopen("index.txt", "w");
fwrite($fopen, "This is the best file on this planet. Please don't argue with me on this one.");

fwrite($fopen, "This is another content, This is the best file on this planet. Please don't argue with me on this one.");

fwrite($fopen, "write three.\n");
fclose($fopen);


$fopen = fopen("index.txt", "a");
fwrite($fopen, "This is the best file on this planet. Please don't argue with me on this one.");

fwrite($fopen, "This is another content, This is the best file on this planet. Please don't argue with me on this one.");

fwrite($fopen, "write three.\n");
fclose($fopen);
?>
2 changes: 2 additions & 0 deletions files/index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is the best file on this planet. Please don't argue with me on this one.This is another content, This is the best file on this planet. Please don't argue with me on this one.write three.
This is the best file on this planet. Please don't argue with me on this one.This is another content, This is the best file on this planet. Please don't argue with me on this one.write three.
18 changes: 18 additions & 0 deletions function/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<p>php function</p>
<?php
function processMarks($marksA){
$sum = 0;
foreach($marksA as $value){
$sum+=$value;
}
return $sum;
}

$farhad = [40,50,60,70,80,90,100];
$sumMarks = processMarks($farhad);

$foysal = [30,20,10,40,50,60,70];
$sumMarksf = processMarks($foysal);
echo "Total marks by farhad is $sumMarks <br> ";
echo "Total marks by foysal is $sumMarksf ";
?>
15 changes: 15 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<p>php function</p>
<?php
function processMarks($marksA){
$sum = 0;
foreach($marksA as $value){
$sum+=$value;
}
return $sum;
}

$farhad = [40,50,60,70,80,90,100];
$sumMarks = processMarks($farhad);

echo $sumMarks;
?>
66 changes: 66 additions & 0 deletions multiArray/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php


$arr = array('this', 'that', 'what');

echo "Array : $arr[0] , $arr[1] , $arr[2] <br>";

$arr = ['this', 'that', 'what'];

echo "Array : $arr[0] , $arr[1] , $arr[2] <br>";

$associate = array(
'farhad' => 'hi',
'foysal' => 'hello',
'moni' => 'assalamualaikum',
5=> 'WalaikumAssalam'
);

echo "Farhad : ".$associate['farhad']. ", Foysal : " .$associate['foysal']. ", Moni : " .$associate['moni'] ;


echo "<br> $associate[5] <br>";

foreach($associate as $key => $value){
echo "User ~ $key : $value <br>";
}

$multiArray = array(
array(2,5,7,8),
array(1,3,6,5),
array(4,5,9,6),
array(2,3,1,2));

// echo var_dump($multiArray);

// echo $multiArray[1][0];
for($i=0; $i<count($multiArray); $i++){
echo var_dump($multiArray[$i]);
echo "<br>";
}

for($i=0; $i<count($multiArray); $i++){
for($j = $i; $j<count($multiArray[$i]); $j++){
echo " ".$multiArray[$i][$j];
}
echo "<br>";
}

for($i=0; $i<count($multiArray); $i++){
for($j = $i; $j<count($multiArray[$i]); $j++){
echo "".$multiArray[$j][$i]." ";
}
echo "<br>";
}

for($i=0; $i<count($multiArray); $i++){
for($j = 0; $j<count($multiArray[$i]); $j++){
echo " ".$multiArray[$i][$j];
}
echo "<br>";
}




?>

0 comments on commit 9f88d41

Please sign in to comment.