php tutorial - PHP - what is php - PHP Tutorial - php programming - learn php - php code - php script
What is PHP - How PHP works
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - php-interpreter](https://wikitechy.com/php/img/php-images/php-interpreter.jpg)
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - what is php](https://wikitechy.com/php/img/php-images/what-is-php.png)
What is web server
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server](https://wikitechy.com/php/img/php-images/web-server.png)
http://www.facebook.com/home.php
- The above URL tells the server facebook.com to run the programhome.php and send back its output
Server-Side web programming
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server - server side programming](https://wikitechy.com/php/img/php-images/server-side-programming.png)
- Dynamically edit, change or add any content to a Web page
- Respond to user queries or data submitted from HTML forms
- Access any data or databases and return the results to a browser
- Customize a Web page to make it more useful for individual users
- Provide security since your server code cannot be viewed from a browser
- contains software that allows it to run server side programs
- sends back their output as responses to web requests
- we use PHP
Lifecycle of a PHP web request
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server - php life cycle](https://wikitechy.com/php/img/php-images/php-life-cycle.png)
Why PHP?
- as of November 2006, there were more than 19 million websites (domain names) using PHP.
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server - php hello world](https://wikitechy.com/php/img/php-images/php-hello-world.png)
Viewing PHP output
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server - php hello world](https://wikitechy.com/php/img/php-images/php-form.png)
PHP syntax template
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server - php syntax](https://wikitechy.com/php/img/php-images/php-syntax.png)
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server - php syntax](https://wikitechy.com/php/img/php-images/consol-output-print.png)
Single Page in PHP
<form action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="post"
…
click below button to copy the code. php tutorial - team
php validation
if (form has been submitted) {
// validate form
}
if (valid submission) {
// action data
} else {
// (re)display form
}
click below button to copy the code. php tutorial - team
if (form has been submitted) {
// validate form
}
…can be implemented as…
if (isset($_POST[‘submit’])) {
// validate form
}
click below button to copy the code. php tutorial - team
Maintain separation in php code - Write safe code in PHP
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server - php syntax](https://wikitechy.com/php/img/php-images/safe-code-in-php.png)
Accumulate errors.. - Catch Errors
$errors = 0;
$errmsg = ‘’;
$clean = array();
if (isset($_POST[‘submit’])) {
if ($_POST[‘value’] is VALID) {
$clean[‘value’] = $_POST[‘value’];
} else {
$errors++;
$errmsg .= ‘data not valid because…’;
}
// continue testing other fields..
}
click below button to copy the code. php tutorial - team
Now to action or display..
if (form has been submitted) {
// validate form
}
if (valid submission) {
// action data
} else {
// (re)display form
}
click below button to copy the code. php tutorial - team
if (isset($_POST[‘submit’])) &&
$errors===0) {
// action data
} else {
// (re)display form
}
click below button to copy the code. php tutorial - team
Redisplay form in PHP
// if (re)displaying form: print
// error message if redisplaying
if ($error>0) {
echo “<p>errors: $errmsg</p>";
}
click below button to copy the code. php tutorial - team
<label for=“email">Email:</label>
<input name=“email"
size="40"
value="<?php echo
isset($clean[‘email']) ?
htmlentities($clean[‘email']) :
‘default'; ?>"
id=“email"
type="text“ />
click below button to copy the code. php tutorial - team
![php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server - php syntax - php tutorials](https://wikitechy.com/php/img/php-images/php-tutorials.png)