PHP Constants – Const in PHP In Hindi

PHP

PHP ConstantsConst in PHP In Hindi – PHP Const Function Ko Ham Class Ke Under Istemal Karte Hai, Const Variable Ki Value Ko Change Nhi Kar Sakte Hai |

Const in PHP In Hindi

Const Keyword Class Ke Under Define Kiya Jata Hai And Ye Case-sensitive Hota Hai, Or Ye Recommend Karta Hai Ki Constant Name All Upper Case Me Hone Chahiye |

Agar Hame Class Ke Bahar Const Ko Access Karna Hai To Uske Liye Aap resolution operator (::) with Name Ka Sath Istemal Kar Sakte Hai And Ise Ham Niche Example Ke Sath Understand Karte Hai |

Also Read – PHP What is OOP

Example:

<?php
  class hello{
  const MESSAGE_CONSTANT = "I'm Danish Ali";
}
echo hello::MESSAGE_CONSTANT;
?>

Output:

I'm Danish Ali

Agar Hame const Keyword Ki Value Ko Class Ke Under Access Karna Hai To Uske Liye self Keyword Ka Istemal karte Hai, Aap Niche Diye Example Ko Dekh Sakte Hai |

Example:

<?php
  class hello{
  const MESSAGE_CONSTANT = "I'm Danish Ali";
  public function Man() {
    echo self::MESSAGE_CONSTANT;
  }
}
$class1 = new hello();
$class1-> Man();
?>

Output:

I'm Danish Ali

Aap Upper Diye Gaye Output Ko Check Kar Sakte Hai Ki Const Keyword Ka Istemal Kaha Par Kiya Jata Hai |

Friends Mujhe Umeed Hai Ki Aapko PHP In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

Also, Read

Leave a Reply

Your email address will not be published. Required fields are marked *