Related Topics

what is Protocols in Hindi

What is a Program in Hindi

What is a Secure Connection in Hindi

Introduction to WWW in Hindi

What are Development Tools in Hindi

What is a Web Browser in Hindi

What is a Server in Hindi

What is a UNIX Web Server in Hindi

What is Logging Users in Hindi

What is Dynamic IP Web Design in Hindi

Web Site Design Principles in Hindi

Site Planning in Hindi

Website Navigation in Hindi

what is Web Systems Architecture in Hindi

Architecture of Web-Based Systems in Hindi

Client-Server Architecture in Hindi

What is Caching in Hindi

: Proxies in Hindi

What is an Index in Hindi

What is a Load Balancer in Hindi

What is a Queue in Hindi

Web Application Architecture in Hindi

JavaScript in Hindi

Client-Side Scripting in Hindi

Introduction to Simple JavaScript in Hindi

: JavaScript Variables in Hindi

What is a Function in JavaScript in Hindi

What are Conditions in JavaScript in Hindi

What are Loops in JavaScript in Hindi

What is Repetition (Looping) in JavaScript? in Hindi

What is an Object in JavaScript in Hindi

JavaScript Own Objects in Hindi

DOM in Hindi

What is a Web Browser Environment in Hindi

Forms in JavaScript in Hindi

DHTML in Hindi

What are Events in DHTML in Hindi

Browser Control in JavaScript in Hindi

AJAX in Hindi

AJAX-based Web Application in Hindi

Alternatives to AJAX in Hindi

XML in Hindi

Uses of XML in Hindi

Simple XML in Hindi

XML Key Components in Hindi

What is DTD (Document Type Definition) in Hindi

What is XML Schema (XSD) in Hindi

XML with Application in Hindi

XSL in Hindi

XSLT in Hindi

Web Service in hindi

PHP in Hindi

Server-Side Scripting in Hindi

PHP Arrays in Hindi

PHP Functions in Hindi

PHP Forms in Hindi

Advanced PHP Databases in Hindi

Server Connection in PHP in Hindi

Database Creation in PHP in Hindi

Understanding Database Selection in PHP in Hindi

PHPMyAdmin in Hindi

Database Bugs in Hindi

PHP Database Query in Hindi

Related Subjects

Introduction to Basic Commands in PHP in Hindi

RGPV University / DIPLOMA_CSE / Web Technology

Introduction to Basic Commands in PHP

Introduction to Basic Commands in PHP

PHP (Hypertext Preprocessor) एक server-side scripting language है, जो dynamic web pages बनाने के लिए इस्तेमाल होती है। PHP को mainly web development में उपयोग किया जाता है और ये एक powerful tool है जो HTML में embedded होता है। इस लेख में हम PHP के कुछ basic commands को समझेंगे, जो एक student के लिए बहुत important हैं। PHP के fundamental commands को समझकर, आप web development के projects में आसानी से काम कर सकते हैं।

1. Echo and Print in PHP

PHP में output generate करने के लिए सबसे commonly used commands हैं echo और print। ये दोनों commands web page पर text display करने के लिए उपयोग होते हैं, लेकिन इनके बीच कुछ differences भी हैं।

  • Echo - यह एक language construct है जो data को output में भेजने के लिए उपयोग होता है। इसमें multiple parameters को comma से separate करके भेज सकते हैं। इसे parentheses के साथ या बिना parentheses के इस्तेमाल किया जा सकता है।
  • Print - यह एक expression है और इसे सिर्फ एक argument के साथ use किया जा सकता है। print हमेशा 1 return करता है, जबकि echo कुछ return नहीं करता।

Code Example:

2. Variables in PHP

PHP में variables किसी भी data ko store करने के लिए उपयोग होते हैं। हर variable की शुरुआत $ symbol से होती है, और variable name को alphabet या underscore से शुरू करना होता है। PHP में variables case-sensitive होते हैं, मतलब $Var और $var अलग-अलग variables हैं।

  • Variable Declaration: PHP में variable declare करने के लिए आपको value assign करनी होती है। Example: $name = "John";
  • Data Types in Variables: PHP में variable की data type dynamic होती है, इसका मतलब है कि आप एक ही variable में different types की values store कर सकते हैं।

Code Example:

3. Data Types in PHP

PHP में data types की 4 main categories होती हैं:

  • Scalar Types: इनमें integers, floating point numbers (floats), booleans और strings आते हैं।
  • Compound Types: इनमें arrays और objects आते हैं।
  • Special Types: इसमें NULL और resources आते हैं।

Code Example (Different Data Types):

4. Arrays in PHP

PHP में arrays का उपयोग एक से अधिक values को store करने के लिए किया जाता है। Arrays indexed (numeric) या associative (key-value pair) हो सकते हैं।

  • Indexed Arrays: इसमें elements index numbers के जरिए store होते हैं।
  • Associative Arrays: इसमें elements के लिए custom keys assign की जाती हैं।

Code Example:

"John", "age" => 25); // Associative Array echo $person["name"]; // Output: John ?>

5. Loops in PHP

Loops का उपयोग किसी task को multiple times perform करने के लिए किया जाता है। PHP में 3 प्रकार के loops होते हैं:

  • For Loop: जब आपको fixed number of times loop run करना हो, तब for loop का उपयोग करते हैं।
  • While Loop: जब तक condition true रहे, loop execute होता रहेगा।
  • Foreach Loop: यह loop primarily arrays और objects के लिए उपयोग होता है।

Code Example (For Loop):

"; } ?>

Code Example (While Loop):

"; $i++; } ?>

Code Example (Foreach Loop):

"; } ?>

FAQs

PHP (Hypertext Preprocessor) एक server-side scripting language है, जो dynamic web pages और applications बनाने के लिए उपयोग होती है। इसे HTML के साथ embed करके web pages पर output generate किया जाता है।

Echo: Echo एक language construct है, जो multiple parameters accept कर सकता है।
Print: Print एक expression है, जो सिर्फ एक parameter accept करता है और हमेशा 1 return करता है, जबकि echo कुछ return नहीं करता।

PHP में variables एक placeholder होते हैं जिनमें data store किया जाता है। सभी variables $ symbol से शुरू होते हैं और इनमें numeric, string, boolean जैसे data types store किए जा सकते हैं।

PHP में data types 4 categories में बाँटे जाते हैं:
Scalar Types: Integer, Float, String, Boolean
Compound Types: Arrays, Objects
Special Types: NULL, Resource

PHP में arrays का उपयोग multiple values store करने के लिए किया जाता है। Arrays दो प्रकार के होते हैं: Indexed Arrays और Associative Arrays। Indexed Arrays में values index numbers से होती हैं, जबकि Associative Arrays में custom keys assign की जाती हैं।

For Loop: For loop का उपयोग तब किया जाता है जब हमको fixed number of iterations चाहिए होती हैं।
While Loop: While loop तब तक execute होता है जब तक उसकी condition true रहती है, यह number of iterations पर depend नहीं करता।

Please Give Us Feedback