What is PHP ?
English Version :
PHP stands for Hypertext Preprocessor.
PHP is a server-side scripting language used to create dynamic web pages. PHP runs on the server, not in the browser.
What does Server-Side mean?
PHP does not run in the browser. It runs on the server
Complete Flow:
- The user enters a URL in the browser example.com/index.php
- The request goes to the web server.
- The server detects a .php file and sends it to the PHP interpreter
- PHP executes the code:
-
Fetches data from the database
-
Runs business logic
- Generates HTML output
-
- The server sends only the final HTML to the browser.
Note: The PHP code is never visible in the browser
Hindi version :
PHP (Full form of PHP Hypertext Preprocessor) एक Server-side scripting language है |जो Dynamic web pages बनाने के लिए use होती है।
Dynamic का मतलब: हर user को अलग-अलग data दिख सकता है (Database से data लेकर user को website में दिखाई देता हैं)
Server-side का मतलब:
PHP browser में नहीं चलती, ये server पर चलती है|
Step by Step पूरा flow समझो:
-
User browser में URL डालता है example.com/index.php
-
Request server पर जाती है (Apache/Nginx)
-
Server PHP को execute करता है
-
PHP कैसे execute होती है :
-
Database से data लाती है
-
Logic run करती है
-
HTML बनाती है
-
Browser को सिर्फ final HTML output मिलता है
Note : PHP code कभी browser में नहीं दिखता
What is PHP and what does it stand for?
PHP stands for Hypertext Preprocessor (originally Personal Home Page). It is a widely-used open-source server-side scripting language that is especially suited for web development.
Key characteristics:
- Server-side execution
- Embedded in HTML
- Cross-platform compatibility
- Supports multiple databases
- Large community and ecosystem
What are the differences between echo and print in PHP?
Both echo and print are used to output data in PHP, but they have subtle differences:
- echo: Can take multiple parameters (comma-separated), does not return a value, slightly faster
- print: Takes only one argument, always returns 1, can be used in expressions
echo "Hello", " World"; // Works
print "Hello World"; // Works
$result = print "test"; // $result is 1
Explain the difference between == and === in PHP.
These are comparison operators with different strictness levels:
==(Loose comparison): Compares values after type juggling."5" == 5istrue===(Strict comparison): Compares both value AND type."5" === 5isfalse
Best practice: Always use === to avoid type coercion bugs.
var_dump(0 == "foo"); // true (PHP 7) – Dangerous!
var_dump(0 === "foo"); // false – Safe!