Unit 1 PHP Detailed Explanation
Unit 1 PHP Detailed Explanation
1. What is PHP?
that is especially suited for web development and can be embedded into HTML. It is executed on
the server, and the output is sent to the client browser in plain HTML format. PHP was originally
created by Rasmus Lerdorf in 1994. It started as a set of CGI scripts for tracking website visitors and
2. Features of PHP
- Server-Side Execution
- Error Reporting
- Large Community
3. PHP Syntax
<?php
?>
<html>
<body>
<h2>Today is:</h2>
<?php
?>
</body>
</html>
- Functions
5. PHP Variables
Declaration:
$var1 = "Welcome";
$var2 = 123;
Rules:
- Start with $
- Case-sensitive
- String: "Hello"
- Integer: 100
- Float: 10.5
- NULL: NULL
- Resource: fopen()
7. Comments in PHP
- Single-line: // or #
- Multi-line: /* ... */
8. Output Statements
9. PHP Operators
- Arithmetic: +, -, *, /, %
- Assignment: =, +=, -=
- String: . (concatenation)
- do-while
Example:
development.
14. Best Practices
- Validate inputs
<input type="submit">
</form>
welcome.php:
<?php
$name = $_POST['name'];
?>
Conclusion:
Unit 1 covers core PHP elements like syntax, variables, data types, conditionals, loops, and