← Back to PHP Course | Chapter 1: Introduction & Basics | Lesson 2 of 13

PHP History और Features

PHP एक छोटे homemade tool की तरह शुरू हुआ जिसे एक व्यक्ति ने अपने ही web page पर visitors count करने के लिए बनाया था। सालों में यह बढ़ा, एक छोटी lemonade stand की तरह जो एक बड़ी shop बन गई।

PHP का History

Rasmus Lerdorf ने 1994 में पहला version अपने personal homepage के visits track करने के लिए छोटे tools के एक set के रूप में लिखा, इसीलिए original name 'Personal Home Page' पड़ा। जैसे-जैसे यह एक personal script collection से एक general-purpose web language में बढ़ा, इसे फिर से लिखा और recursive नाम 'PHP: Hypertext Preprocessor' दिया गया।

उदाहरण: History of PHP

php
<?php
// Rasmus Lerdorf's 1994 "Personal Home Page" tools grew into PHP: Hypertext Preprocessor
echo "PHP has been evolving since 1994.";
?>

Open Source

PHP का source code और interpreter इस्तेमाल और modify करने के लिए free हैं, और एक बड़े open community के दशकों के contributions ने इसकी standard library, इसकी performance, और PHP 7 की speed improvements तथा PHP 8 के JIT compiler जैसे major language shifts को आकार दिया है।

उदाहरण: Open Source

php
<?php
// Anyone can inspect or modify the PHP interpreter itself -- it's open source
echo "PHP version running here: " . phpversion();
?>

Platform Independence

वही PHP script आमतौर पर बिना बदले Windows, Linux, या macOS पर चलती है, क्योंकि PHP खुद platform के अंतर (file paths, line endings, वगैरह) को handle करता है बजाय इस बोझ को आपके code पर डालने के — यही एक बड़ी वजह है कि यह portable web hosting के लिए एक default choice बन गया।

उदाहरण: Platform Independence

php
<?php
// The same script runs unmodified on Windows, Linux, or macOS
echo "Directory separator on this OS: " . DIRECTORY_SEPARATOR;
?>

Speed और Efficiency

Modern PHP (खासकर PHP 7 और 8) optimized bytecode में compile होता है और, PHP 8 से, hot code paths को JIT-compile कर सकता है, जिसने typical request/response web workloads के लिए PHP और lower-level languages के बीच कभी मौजूद performance gap को काफ़ी हद तक बंद कर दिया।

उदाहरण: Speed and Efficiency

php
<?php
// Declare `$start`, set to `microtime(true)`
$start = microtime(true);
// Classic for-loop: `$i = 0; $i < 100000; $i++`
for ($i = 0; $i < 100000; $i++) {
    // Declare `$total`, set to `$i * 2`
    $total = $i * 2;
}
// Print "Compiled bytecode ran in " . round(microtime(true) - $start, 4) . "s" to the output
echo "Compiled bytecode ran in " . round(microtime(true) - $start, 4) . "s";
?>

Loose Type Language

PHP loosely typed है: आप पहले से किसी variable का type declare नहीं करते, और जब किसी operation को ज़रूरत हो तो PHP automatically types के बीच convert कर देता है (जैसे एक string और एक number को combine करना)।

यह आपकी पहली काम करने वाली script लिखने की barrier कम करता है, हालाँकि यही वजह है कि PHP ने बड़े codebases के लिए बाद के versions में optional strict typing और type declarations भी add किए।

उदाहरण: Loose Type Language

php
<?php
$value = "5" + 3;
echo $value;
// PHP converted the string "5" to a number automatically
?>
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. पुराने benchmarks देखकर यह मान लेना कि PHP धीमा है, जबकि PHP 7 और 8 optimized bytecode में compile होते हैं (opcache के साथ) और PHP 5 से कहीं ज़्यादा तेज़ हैं।
  2. PHP 5 के लिए लिखे गए tutorials follow करना और mysql_* functions जैसी हटाई गई features इस्तेमाल करना, जो modern PHP में अब exist नहीं करतीं।
  3. यह मान लेना कि एक PHP version के लिए लिखी गई script किसी भी दूसरे version पर बिना बदले चलेगी, PHP 8 में introduce हुए जैसे version-specific changes check किए बिना।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.