PHP Output
PHP Output
Coding
<?php
$a = 0;
$b = 1;
echo "Fibonacci Series Numbers Less Than 100 : \n";
while ($a < 100) {
echo $a . "\n";
$temp = $a;
$a = $b;
$b = $temp + $b;
}
?>
Output
Output
Program – 3 - page views (refresh) count.
Coding
<?php
session_start(); // Start the session
// Check if the page views count is set in the session
if (!isset($_SESSION['page_views'])) {
$_SESSION['page_views'] = 1; // Initialize the count if not set
} else {
$_SESSION['page_views']++; // Increment the count on each refresh
}
?>
<p>This page has been viewed <?php echo $_SESSION['page_views']; ?> times.</p>
Output
<?php
// Function to increment and get the hit count
function incrementAndGetHitCount() {
// Check if 'hit_count' cookie is set
$hitCount = isset($_COOKIE['hit_count']) ? $_COOKIE['hit_count'] + 1 : 1;
// Set the 'hit_count' cookie with updated value and expiration time
setcookie('hit_count', $hitCount, time() + 3600 * 24);
Output
Program – 6 – perform Read, Write, Append operation on file.
Coding
<?php
// Read file
$filename = "test.txt";
$file = fopen($filename, "r");
$content = fread($file, filesize($filename));
fclose($file);
echo "File Content: " . $content;
// Write file
$filename = "test.txt";
$content = "New content written";
$file = fopen($filename, "w");
fwrite($file, $content);
fclose($file);
// Append file
$filename = "test.txt";
$content = "Appended content";
$file = fopen($filename, "a");
fwrite($file, $content);
fclose($file);
?>
Output
Program – 7 - compute age for a given date.
Coding
<body>
<h2>Age Calculator</h2>
</form>
<?php
if (isset($_GET['dob'])) {
$age = $today->diff($birthDate)->y;
?>
</body>
Output
Coding
Index.php file
<html>
<body>
<input type="submit">
</form>
</body>
</html>
welcome.php file
<html>
<body>
<div class="welcome-container">
</div>
</body>
</html>
Output
Output 9
Program – 9 - display the table content using store procedures.
MYSQL – coding
-- Create a database
USE CollegeDB;
FirstName VARCHAR(50),
LastName VARCHAR(50),
Age INT,
Course VARCHAR(50)
);
DELIMITER //
BEGIN
END //
DELIMITER ;
Program – 10 - My Sql program to create a table student.
Coding
USE school_database;
date_of_birth DATE,
phone_number VARCHAR(15),
address VARCHAR(255)
);
Output