Unit 3 Php Mern Notes
Unit 3 Php Mern Notes
PHP files have extension .php and can include HTML, CSS, JavaScript and PHP code.
Example:
Example - if statement:
<?php
$x = 10;
if ($x > 5) {
echo 'Greater than 5';
}
?>
<?php
for ($i = 0; $i < 5; $i++) {
echo $i;
}
?>
Example:
PHP Arrays
PHP arrays store multiple values: Indexed, Associative, and Multidimensional.
Example:
PHP Functions
Functions in PHP are declared using the function keyword.
Example:
function greet($name) {
return "Hello $name!";
}
Example:
$str = 'Hello';
echo strlen($str); // 5
Example:
Example:
Example:
MongoDB Basics
MongoDB: NoSQL database that stores JSON-like documents.
Express.js Basics
Express.js: Minimal Node.js framework for creating APIs and routes.
Example:
Node.js Basics
Node.js: JavaScript runtime to run JS on the server.
Example:
React.js Basics
React.js: Frontend library to create UI using components.
Single Page Application (SPA) framework.