<?php
for($m=0;$m<=59;$m++)
{
for($s=20;$s<=59;$s++)
{
echo $m." ".$s."<br>";
}
}
?>
<?php
$a=array(10,16,72,15,20);
$max=0;
for($p=0;$p<=4;$p=$p+1)
{
echo $a[$p]."<br>";
if($a[$p]>$max)
{
$max=$a[$p];
}
}
?>
<?php
$a=array(20,15,30,13,16,28,19,62,33,62);
for($p=0;$p<=9;$p=$p+1)
{
print $a[$p]." ".$p."<br>";
}
?>
<?php
$a=array(10,20,30,40,50);
print $a[4];
?>
<?php
$a=array(10,20,30,40,50);
print $a[3];
?>
<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>
<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>
<?php
class abc
{private $a="master";
public function display()
{echo ( $this->$a);
// echo $this->$a."<br>";
}
}
$obj=new abc;
$x=$obj->display();
echo $x;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$a=10;
$b=20;
$c=$a+$b;
echo $c;
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Hit counter</title>
<link rel="stylesheet" type="text/css" href="common.css"/>
</head>
<body>
<h1>A simple hit counter</h1>
<?php
$counterFile="./count.dat";
if(!file_exists($counterFile)) {
if( !( $handle = fopen($counterFile, "w"))) {
die("Cannot create the counter file.");
} else {
fwrite($handle, 0);
fclose($handle);
}
}
if(!($handle= fopen($counterFile, "r"))) {
die("Cannot read the counter file.");
}
$counter= (int) fread($handle, 20);
fclose($handle);
$counter++;
echo "<p>You're visitor No. $counter.</p>";
if( !($handle = fopen($counterFile, "w"))){
die("Cannot open the counter file for writing.");
}
fwrite($handle, $counter);
fclose($handle);
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Listing the contents of a directory</title>
<link rel="stylesheet" type="text/css" href="common.css"/>
</head>
<body>
<h1>Listing the contents of a directory</h1>
<?php
$dirPath= "F:\Course Material\documents\Documents";
function traverseDir($dir) {
echo "<h2>Listing $dir...</h2>";
if( !($handle = opendir($dirPath))) die("Cannot open the directory.");
$files= array();
while ($file = readdir($handle)) {
if($file != "." && $file != "..") {
if(is_dir($dir ."/". $file)) $file.="/";
$files[] = $file;
}
}
sort($files);
echo "<ul>";
foreach($files as $file) echo "<li>$file</li>";
echo "</ul>";
foreach($files as $file) {
if(substr($file, -1) == "/") traverseDir("$dir/" . substr($file, 0, -1));
}
closedir($handle);
}
traverseDir($dirPath);
?>
</body>
</html>
<?php
$a="Mridul Sharma";
$b=substr($a,8,2);
echo $a."<br>";
echo $b;
?>
<?php
$a=1;
while($a<=5)
{
echo $a;
echo " Raman Kumar"."<br>";
echo " House No.403"."<br>";
echo " Sector 06"."<br>";
echo " Panchkula"."<br>";
$a=$a+1;
}
echo "End of Job";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Php Revision</title>
</head>
<body>
<?php
$abc=50;
while($abc<=100)
{
echo $abc." ";
$abc=$abc+5;
}
?>
</body>
</html>
for($m=0;$m<=59;$m++)
{
for($s=20;$s<=59;$s++)
{
echo $m." ".$s."<br>";
}
}
?>
<?php
$a=array(10,16,72,15,20);
$max=0;
for($p=0;$p<=4;$p=$p+1)
{
echo $a[$p]."<br>";
if($a[$p]>$max)
{
$max=$a[$p];
}
}
?>
<?php
$a=array(20,15,30,13,16,28,19,62,33,62);
for($p=0;$p<=9;$p=$p+1)
{
print $a[$p]." ".$p."<br>";
}
?>
<?php
$a=array(10,20,30,40,50);
print $a[4];
?>
<?php
$a=array(10,20,30,40,50);
print $a[3];
?>
<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>
<?php
$a=12345;
$b=number_format($a);
echo $a."<br>";
echo $b;
?>
<?php
class abc
{private $a="master";
public function display()
{echo ( $this->$a);
// echo $this->$a."<br>";
}
}
$obj=new abc;
$x=$obj->display();
echo $x;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$a=10;
$b=20;
$c=$a+$b;
echo $c;
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Hit counter</title>
<link rel="stylesheet" type="text/css" href="common.css"/>
</head>
<body>
<h1>A simple hit counter</h1>
<?php
$counterFile="./count.dat";
if(!file_exists($counterFile)) {
if( !( $handle = fopen($counterFile, "w"))) {
die("Cannot create the counter file.");
} else {
fwrite($handle, 0);
fclose($handle);
}
}
if(!($handle= fopen($counterFile, "r"))) {
die("Cannot read the counter file.");
}
$counter= (int) fread($handle, 20);
fclose($handle);
$counter++;
echo "<p>You're visitor No. $counter.</p>";
if( !($handle = fopen($counterFile, "w"))){
die("Cannot open the counter file for writing.");
}
fwrite($handle, $counter);
fclose($handle);
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Listing the contents of a directory</title>
<link rel="stylesheet" type="text/css" href="common.css"/>
</head>
<body>
<h1>Listing the contents of a directory</h1>
<?php
$dirPath= "F:\Course Material\documents\Documents";
function traverseDir($dir) {
echo "<h2>Listing $dir...</h2>";
if( !($handle = opendir($dirPath))) die("Cannot open the directory.");
$files= array();
while ($file = readdir($handle)) {
if($file != "." && $file != "..") {
if(is_dir($dir ."/". $file)) $file.="/";
$files[] = $file;
}
}
sort($files);
echo "<ul>";
foreach($files as $file) echo "<li>$file</li>";
echo "</ul>";
foreach($files as $file) {
if(substr($file, -1) == "/") traverseDir("$dir/" . substr($file, 0, -1));
}
closedir($handle);
}
traverseDir($dirPath);
?>
</body>
</html>
<?php
$a="Mridul Sharma";
$b=substr($a,8,2);
echo $a."<br>";
echo $b;
?>
<?php
$a=1;
while($a<=5)
{
echo $a;
echo " Raman Kumar"."<br>";
echo " House No.403"."<br>";
echo " Sector 06"."<br>";
echo " Panchkula"."<br>";
$a=$a+1;
}
echo "End of Job";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Php Revision</title>
</head>
<body>
<?php
$abc=50;
while($abc<=100)
{
echo $abc." ";
$abc=$abc+5;
}
?>
</body>
</html>
No comments:
Post a Comment