-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5e7fdd
commit 796029d
Showing
9 changed files
with
165 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php // This is a php tag. If there is no html or other content below the php, we don't need to close the php tag. | ||
|
||
/* ------- Outputting Content ------- */ | ||
|
||
// Echo - Output strings, numbers, html, etc | ||
echo 'Hello'; | ||
echo '<br/>'; | ||
|
||
echo 123; | ||
echo '<br/>'; | ||
|
||
echo '<h1>Hello</h1>'; | ||
|
||
// print - Similar to echo, but a bit slower | ||
print 'Hello'; | ||
echo '<br/>'; | ||
|
||
// print_r - Gives a bit more info. Can be used to print arrays | ||
print_r('Hello'); | ||
echo '<br/>'; | ||
|
||
print_r([1, 2, 3]); | ||
echo '<br/>'; | ||
|
||
// var_dump - Even more info like data type and length | ||
var_dump('Hello'); | ||
echo '<br/>'; | ||
|
||
var_dump([1, 2, 3]); | ||
echo '<br/>'; | ||
|
||
// Escaping characters with a backslash | ||
echo 'You can\'t do that.'; | ||
|
||
$name = 'Ahmed'; | ||
|
||
// If there is more content after the PHP, such as this file, you do need the ending tag. Otherwise you do not. | ||
?> | ||
|
||
<!-- You can output any HTML that you want within a .php file --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>My PHP Website</title> | ||
</head> | ||
<body> | ||
<!-- You can output PHP including variables, etc --> | ||
<h1>Hello <?php echo $name; ?></h1> | ||
<!-- You may only drop the semi-colon after a statement when the statement is followed immediately by a closing PHP tag ?>. --> | ||
<h1>Hello <?= $name ?></h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* Rules for PHP variables: | ||
* A variable starts with the $ sign, followed by the name of the variable | ||
* A variable name must start with a letter or the underscore character | ||
* A variable name cannot start with a number | ||
* A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) | ||
* Variable names are case-sensitive ($age and $AGE are two different variables) | ||
*/ | ||
|
||
$name = 'Ahmed'; // String // Can be single or double quotes | ||
$age = 28; // Integer | ||
$has_kids = true; // Boolean | ||
$number_of_kids = 1; // Boolean | ||
$cash_on_hand = 1_00_000.55; //Float | ||
|
||
/* --- Adding variables to strings -- */ | ||
echo "<br />"; | ||
// Double quotes can be used to add variables to strings | ||
echo "$name is $age years old"; | ||
|
||
// deprecated at php8.3 | ||
// echo "${name} is ${age} years old"; | ||
|
||
// Concatenate Strings | ||
|
||
|
||
if($has_kids) { | ||
echo '<p>He has Kids.</p>'; | ||
} | ||
|
||
echo '<h3>' . 'He has ' . $cash_on_hand . ' BDT on hand.</h3>'; | ||
|
||
// Arithmetic Operators | ||
|
||
echo 5 + 5; | ||
echo "<br/>"; | ||
echo 10 - 6; | ||
echo "<br/>"; | ||
echo 5 * 10; | ||
echo "<br/>"; | ||
echo 10 / 2; | ||
echo "<br/>"; | ||
|
||
// Constants - Cannot be changed | ||
define('HOST', 'localhost'); // Old Way | ||
const USER = 'root'; // Latest | ||
|
||
var_dump(HOST, USER); |