0% found this document useful (0 votes)
14 views4 pages

PHP Notes

The document provides examples of PHP data types, including strings, integers, floats, and booleans, along with basic usage in echo statements. It also demonstrates the use of GET and POST methods in HTML forms for user input, including username and password submission, as well as quantity calculations for an item. Additionally, it covers various mathematical functions in PHP, such as absolute value, rounding, and generating random numbers.

Uploaded by

sheik8610
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

PHP Notes

The document provides examples of PHP data types, including strings, integers, floats, and booleans, along with basic usage in echo statements. It also demonstrates the use of GET and POST methods in HTML forms for user input, including username and password submission, as well as quantity calculations for an item. Additionally, it covers various mathematical functions in PHP, such as absolute value, rounding, and generating random numbers.

Uploaded by

sheik8610
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Php data types

<?php
$name = "Umar sheik";
$food = "egg";
$age = 19;
$gpa = 8.5;
$price = 5.88;
$online = true;

echo "{$name} like {$food}<br>";


echo "you are {$age} years old<br>";
echo "your gpa is {$gpa}<br>";
echo "your egg is \${$price}<br>";
echo "online status <b>{$online}</b> if false nothing
displays";

?>

GET AND POST METHOD


<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>get and post</title>
</head>

<body>
<form action="index.php" method="post">
<label>Username : </label><br>
<input type="text" name="username"><br>
<label>password : </label><br>
<input type="password" name="pass"><br>

<input type="submit" value="Log in"><br>

</form>
</body>

</html>
<?php
echo "{$_POST["username"]} <br>";
echo $_POST["pass"];

?>

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>get and post</title>
</head>

<body>
<form action="index.php" method="post">
<label>Quantity : </label><br>
<input type="text" name="quantity"><br>
<input type="submit" value="total"><br>

</form>
</body>

</html>
<?php
$item = "apple";
$price = 21.43;
$quantity = $_POST["quantity"];
$total = null;

$total = $quantity * $price;

echo "you have ordered {$quantity} x {$item}/s<br>";


echo "Your total is : {$total}"
?>
Math functions
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>get and post</title>
</head>

<body>
<form action="index.php" method="post">
<label>X : </label><br>
<input type="text" name="x"><br>
<label>Y : </label><br>
<input type="text" name="y"><br>
<label>Z : </label><br>
<input type="text" name="z"><br>
<input type="submit" value="total"><br>

</form>
</body>

</html>
<?php
$x = $_POST["x"];
$y = $_POST["y"];
$y = $_POST["z"];
$total = null;

$total = abs($x);
$total = round($x);
$total = floor($x);
$total = ceil($x);

$total = sqrt($x);
$total = pow($x, $y);
$total = max($x, $y, $z);
$total = min($x, $y, $z);
$total = pi();
$total = rand(1, 6);

echo $x;

?>

You might also like