Hướng dẫn php in hindi

Learn PHP

PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.

PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.

Start learning PHP now »


Easy Learning with "PHP Tryit"

With our online "PHP Tryit" editor, you can edit the PHP code, and click on a button to view the result.

Example



echo "My first PHP script!";
?>


Try it Yourself »

Click on the "Try it Yourself" button to see how it works.


PHP Exercises



PHP Examples

Learn by examples! This tutorial supplements all explanations with clarifying examples.

See All PHP Examples


PHP Quiz Test

Learn by taking a quiz! This quiz will give you a signal of how much you know, or do not know, about PHP.

Start PHP Quiz!


My Learning

Track your progress with the free "My Learning" program here at W3Schools.

Log into your account, and start earning points!

This is an optional feature, you can study W3Schools without using My Learning.

Hướng dẫn php in hindi


PHP References

W3Schools' PHP reference contains different categories of all PHP functions, keywords and constants, along with examples.


Kickstart your career

Get certified by completing the course

Get certified

w3schoolsCERTIFIED.2022



PHP मे Decision Making Statements विभिन्न कार्यों के आधार पर विभिन्न प्रकार के कार्यों को करने के लिए उपयोग किया जाता है. इसमे if, elseif ...else और Switch Statements का उपयोग अलग Condition मे Decision Making के लिए किया जाता है. आप अपने Decision लेने के लिए Code में Conditional Statements का उपयोग कर सकते हैं.

PHP Three Decision Making Statements को Supports करता है.

  • if...else statement

  • elseif statement

  • switch statement

If...Else Statement

If...Else Statement कुछ Code को Executes करता है यदि कोई Condition True है और दूसरे Code मे अगर वह Condition False है तो हम if...else Statement का उपयोग करते है.



   
      If...Else Statement Example
   
   
      
   


Output

Have a nice day!

ElseIf Statement

अगर आप कुछ Code को Executes करना चाहते हैं और कई Conditions में से एक सही है तो आप elseif Statement का उपयोग कर सकते है.


   
   
      ElseIf Statement Example
      
        
        
   


Output

Have a nice day!

Switch Statement

Switch Statement का उपयोग Execute किये जाने वाले Code के कई Block को Select करने के लिए किया जाता है.


   
   
      Switch Statement Example
      
        
      
   


Output

Today is Saturday



PHP Articles in Hindi


Decision making स्टेटमेंट्स का उपयोग करके प्रोग्राम को अलग अलग condition के अनुसार execute कराया जा सकता है।

PHP में decision making statements निम्न है।

  1. if
  2. if else
  3. if else if
  4. switch

1) if

इसे simple if भी कहते है, अगर इसमें दी हुई condition true होती है तब ही इसका code block(statements) execute होगा।

Syntax

if(condition){
// statements
}

Example

2) if else

if में दी हुई condition अगर true होगी तो if के statements execute होगा अगर false हुआ तब ही else के statements execute होंगे।

else में condition कभी उपयोग नहीं किया जाता है।

else हमेशा end में ही use किया जाता है।

Syntax

if(condition){
 // statements
}
else
{
// statements
}

3) if else if

अगर प्रोग्राम में एक से अधिक conditions को check कर statements execute कराने के लिए उपयोग किया जाता है।

Syntax

if(condition)
{
// statements
}
else if(condition)
{
// statements
}
else if(condition)
{
// statements
}
else
{
// statements
}

Example

if else if में जितनी बार चाहे उतनी बार उपयोग कर सकते है और else हमेशा आखरी में ही use होगा, ये optional होता है use कर भी सकते है और नहीं भी।

4) switch

switch भी if else if की तरह multiple कंडीशन चेक करता है ।

Syntax

switch (x) {
    case label1:
        code execute होगा अगर  x=label1;
        break;
    case label2:
        code execute होगा अगर x=label2;
        break;
    case label3:
        code execute होगा अगर x=label3;
        break;
   default:
        code execute होगा अगर सभी labels मैच नहीं होंगे तो;
}

Example

Switch कैसे काम करता है ?

switch में label में दी हुई वैल्यूज को दिए हुए वैल्यू के साथ मैच करता है, जो label मैच होता है उसके statements एक्सेक्यूट होते है और break keyword का उपयोग स्टेटमेंट्स के execution के बाद स्विच से control को बहार transfer करना होता है। अगर कोई भी लेबल मैच नहीं होता तब default ब्लॉक के स्टेटमेंट्स execute होते है और यह ऑप्शनल है (use कर सकते है और नहीं भी)