{"id":1318,"date":"2021-06-11T19:01:14","date_gmt":"2021-06-11T13:31:14","guid":{"rendered":"https:\/\/selfimagination.in\/tips\/?p=1318"},"modified":"2021-06-11T19:17:56","modified_gmt":"2021-06-11T13:47:56","slug":"php-constant","status":"publish","type":"post","link":"https:\/\/selfimagination.in\/tips\/php-constant\/","title":{"rendered":"PHP Constant"},"content":{"rendered":"\n<p class=\"wp-block-zozuk-wphindi\">Constant \u092e\u0947\u0902 \u0939\u092e \u0915\u0947\u0935\u0932 \u090f\u0915 \u092c\u093e\u0930 \u0939\u0940 \u0935\u0948\u0932\u094d\u092f\u0942 Assign \u0915\u0930 \u0938\u0915\u0924\u0947 \u0939\u0948\u0902 \u0914\u0930 \u092b\u093f\u0930 \u0909\u0938\u0915\u093e \u0909\u092a\u092f\u094b\u0917 \u0915\u0939\u0940 \u092d\u0940 \u0915\u0930 \u0938\u0915\u0924\u0947 \u0939\u0948\u0902 \u0964 \u0906\u0907\u092f\u0947 \u0939\u092e \u0905\u092c PHP Constant \u0915\u0947 Syntax \u0915\u094b \u0938\u092e\u091d\u0924\u0947 \u0939\u0948\u0902 \u0964<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax <\/h2>\n\n\n\n<p class=\"wp-block-zozuk-wphindi\">Constant \u092c\u0928\u093e\u0928\u0947 \u0915\u0947 \u0926\u094b \u0924\u0930\u0940\u0915\u0947 \u0939\u0948\u0902 \u0964<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\/\/1.\ndefine(\"MYCONSTANT\",&nbsp;\"Hello\");\necho&nbsp;MYCONSTANT;&nbsp;\/\/&nbsp;outputs&nbsp;\"Hello\"\n\n\/\/2.\nconst&nbsp;MYCONSTANT&nbsp;=&nbsp;'Hello';\necho&nbsp;MYCONSTANT;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Name Rules<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Constant<\/strong> \u092e\u0947\u0902 ($) Sign \u0915\u093e \u0909\u092a\u092f\u094b\u0917 <strong>\u0928\u0939\u0940\u0902 <\/strong>\u0915\u093f\u092f\u093e \u091c\u093e\u0924\u093e \u0939\u0948\u0902 \u0964<\/li><li><strong>Constant<\/strong> \u0915\u093e <strong>Scope<\/strong> \u092a\u0941\u0930\u0947 \u092a\u0947\u091c \u092a\u0930 \u0939\u0940 \u0939\u094b\u0924\u093e \u0939\u0948\u0902 \u0907\u0938\u0915\u0947 \u0932\u093f\u090f \u0915\u094b\u0908 <strong>Scope<\/strong> \u0915\u093e <strong>Rule<\/strong> \u0928\u0939\u0940\u0902 \u0939\u094b\u0924\u093e \u0964<\/li><li><strong>Constant<\/strong> \u0915\u094b \u0939\u092e \u092c\u093e\u0930-\u092c\u093e\u0930 <strong>Define<\/strong> \u0928\u0939\u0940\u0902 \u0915\u0930 \u0938\u0915\u0924\u0947 \u0939\u0948\u0902 \u0914\u0930 \u0928 \u0939\u0940 \u0907\u0938\u0947 <strong>Blank <\/strong>\u0915\u0930 \u0938\u0915\u0924\u0947 \u0939\u0948\u0902 \u0964<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Predefined Constants<\/h2>\n\n\n\n<p class=\"wp-block-zozuk-wphindi\">PHP \u092e\u0947\u0902 \u092c\u0939\u0941\u0924 \u0938\u0947 \u092a\u0939\u0932\u0947 \u0938\u0947 Define \u0915\u093f\u092f\u0947 Constant \u0939\u0948\u0902 \u091c\u093f\u0928\u0915\u093e \u0939\u092e \u0909\u092a\u092f\u094b\u0917 \u0915\u0930 \u0938\u0915\u0924\u0947 \u0939\u0948\u0902 \u0964 \u0907\u0928\u092e\u0947 \u0938\u0947 \u0915\u0941\u091b \u0915\u0947 \u092c\u093e\u0930\u0947 \u092e\u0947\u0902 \u0928\u093f\u091a\u0947 \u0926\u093f\u092f\u093e \u0917\u092f\u093e \u0939\u0948 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php \n    echo '&lt;table border=1>';\n    echo '&lt;tr>&lt;td>PHP_VERSION&lt;\/td>&lt;td>'. PHP_VERSION .'&lt;\/td>&lt;\/tr>';\n     \/\/ add all\n    echo '&lt;\/table >';\n?><\/code><\/pre>\n\n\n\n<p class=\"wp-block-zozuk-wphindi\"><strong>Output<\/strong><\/p>\n\n\n\n<table border=\"1\"><tbody><tr><td>PHP_VERSION<\/td><td>7.3.12<\/td><\/tr><tr><td>PHP_MAJOR_VERSION<\/td><td>7<\/td><\/tr><tr><td>PHP_MINOR_VERSION <\/td><td>3<\/td><\/tr><tr><td>PHP_RELEASE_VERSION <\/td><td>12<\/td><\/tr><tr><td>PHP_VERSION_ID  <\/td><td>70312<\/td><\/tr><tr><td>PHP_EXTRA_VERSION <\/td><td><\/td><\/tr><tr><td>PHP_ZTS  <\/td><td>1<\/td><\/tr><tr><td>PHP_DEBUG  <\/td><td>0<\/td><\/tr><tr><td>PHP_MAXPATHLEN <\/td><td>2048<\/td><\/tr><tr><td>PHP_OS  <\/td><td>WINNT<\/td><\/tr><tr><td>PHP_OS_FAMILY  <\/td><td>Windows<\/td><\/tr><tr><td>PHP_SAPI  <\/td><td>apache2handler<\/td><\/tr><\/tbody><\/table>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Magic Constant<\/h2>\n\n\n\n<p class=\"wp-block-zozuk-wphindi\">PHP \u092e\u0947\u0902 <strong>9 Magic Constant<\/strong> \u0939\u0948\u0902 \u0907\u0928\u0915\u0947 \u0935\u0948\u0932\u094d\u092f\u0942 \u091c\u0939\u093e \u0939\u092e \u0909\u092a\u092f\u094b\u0917 \u0915\u0930\u0924\u0947 \u0939\u0948\u0902 \u0909\u0938\u0915\u0947 \u0905\u0928\u0941\u0938\u093e\u0930 \u092c\u0926\u0932\u0924\u0940 \u0930\u0939\u0924\u0940 \u0939\u0948\u0902 <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>__<strong>LINE__<\/strong> : \u091c\u093f\u0938 \u092d\u0940 \u0932\u093e\u0907\u0928 \u092a\u0930 \u0907\u0938 constant \u0915\u094b \u0932\u093f\u0916\u0947\u0902\u0917\u0947 \u0935\u0939 \u092a\u0930 Current \u0932\u093e\u0907\u0928 \u0928\u0902\u092c\u0930 \u092a\u094d\u0930\u093f\u0902\u091f \u0939\u094b \u091c\u093e\u090f\u0917\u093e \u0964<\/li><li>__<strong>NAMESPACE__ :<\/strong> Current Namespace \u0915\u0947 \u0928\u093e\u092e Print \u0915\u0930\u0928\u0947 \u0915\u0947 \u0932\u093f\u090f \u0964<\/li><li>__<strong>METHOD<\/strong>__: Class \u0915\u0940 \u091c\u093f\u0938 method \u092e\u0947\u0902 \u0939\u092e \u0907\u0938\u0947 \u0932\u093f\u0916\u0947\u0902\u0917\u0947 \u0909\u0938 Method \u0915\u093e \u0928\u093e\u092e Print \u0939\u094b \u091c\u093e\u090f\u0917\u093e \u0964<\/li><li>__<strong>TRAIT__<\/strong> : Trait \u0915\u093e \u0928\u093e\u092e \u092a\u094d\u0930\u093f\u0902\u091f \u0915\u0930\u0928\u0947 \u0915\u0947 \u0932\u093f\u090f \u0964<\/li><li><strong>__CLASS__ : <\/strong>Current Class \u0915\u093e \u0928\u093e\u092e Print \u0915\u0930\u0928\u0947 \u0915\u0947 \u0932\u093f\u090f \u0964<\/li><li>__<strong>FUNCTION<\/strong>__ \u0915\u0930\u0902\u091f Function \u0915\u093e \u0928\u093e\u092e \u0926\u0947\u0916\u0928\u0947 \u0915\u0947 \u0932\u093f\u090f \u0964<\/li><li>__<strong>DIR__<\/strong> Current&nbsp;Directory \u0915\u093e \u0928\u093e\u092e \u0926\u0947\u0916\u0928\u0947 \u0915\u0947 \u0932\u093f\u090f \u0964<\/li><li>__<strong>FILE__<\/strong> Full Path With File name , File name \u0915\u0947 \u0938\u093e\u0925 \u092a\u0942\u0930\u093e Path \u0926\u093f\u0916\u093e\u0908 \u0926\u0947\u0917\u093e \u0964<\/li><\/ul>\n\n\n\n<p class=\"wp-block-zozuk-wphindi\">\u0907\u0938 Example \u0938\u0947 \u0938\u092e\u091d\u0924\u0947 \u0939\u0948\u0902 \u0964  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php \n<strong>namespace MyModel {<\/strong>\n     echo '1. <strong>LINE<\/strong> Line No.  :' . <strong>LINE<\/strong> . nl2br(\"\\r\\n\");\n     echo '2. <strong>FILE<\/strong> File Path :' . <strong>FILE<\/strong> . nl2br(\"\\r\\n\");\n     echo '3. <strong>DIR<\/strong>  Directory :' . <strong>DIR<\/strong> . nl2br(\"\\r\\n\");\n     echo '4. <strong>NAMESPACE<\/strong> :' .  <strong>NAMESPACE<\/strong> . nl2br(\"\\r\\n\");\n\n\n     <strong>function MyFunc()<\/strong> {\n         echo '5. <strong>FUNCTION<\/strong>  :' .  <strong>FUNCTION<\/strong> . nl2br(\"\\r\\n\");\n     }\n     MyFunc(); \n\n\n    <strong>class MyClass<\/strong> {\n         public function <strong>construct() {             echo '6. __CLASS<\/strong> :' .  <strong>CLASS<\/strong> .nl2br(\"\\r\\n\");\n             echo '7.   ClassName::class :' .  ClassName::class . nl2br(\"\\r\\n\");\n         }\n         public function PrintData() {\n             echo '8. <strong>METHOD<\/strong> :' .  <strong>METHOD<\/strong> . nl2br(\"\\r\\n\");\n         }\n         use trait_example;\n     }\n     \n     <strong> trait trait_exampl<\/strong>e {\n            function MyFunc(){\n                echo '9. <strong>TRAIT<\/strong> :' .  <strong>TRAIT<\/strong> . nl2br(\"\\r\\n\");\n            }    \n      }\n\n     $obj = new MyClass;\n     $obj-&gt;PrintData();\n     $obj-&gt;MyFunc();\n}\n?&gt;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-zozuk-wphindi\">\u092f\u0926\u093f \u0906\u092a \u090f\u0915 PHP \u092a\u0947\u091c \u092a\u0930 \u0909\u092a\u0930\u094b\u0915\u094d\u0924 Script \u0915\u094b Paste \u0915\u0930 Execute \u0915\u0930\u0947\u0902\u0917\u0947 \u0924\u094b \u0907\u0938 \u092a\u094d\u0930\u0915\u093e\u0930 \u0938\u0947 \u0906\u0909\u091f\u092a\u0941\u091f \u092a\u094d\u0930\u093e\u092a\u094d\u0924 \u0939\u094b\u0917\u093e \u0964<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"markup\" class=\"language-markup\">1. __LINE__ Line No. :4\n2. __FILE__ File Path :D:\\wamp64\\www\\example\\const.php\n3. __DIR__ Directory :D:\\wamp64\\www\\example\n4. __NAMESPACE__ :MyModel\n5. __FUNCTION__ :MyModel\\MyFunc\n6. __CLASS__ :MyModel\\MyClass\n7. ClassName::class :MyModel\\ClassName\n8. __METHOD__ :MyModel\\MyClass::PrintData\n9. __TRAIT__ :MyModel\\trait_example<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Syntax Name Rules Constant \u092e\u0947\u0902 ($) Sign \u0915\u093e \u0909\u092a\u092f\u094b\u0917 \u0928\u0939\u0940\u0902 \u0915\u093f\u092f\u093e \u091c\u093e\u0924\u093e \u0939\u0948\u0902 \u0964 Constant \u0915\u093e Scope \u092a\u0941\u0930\u0947 \u092a\u0947\u091c \u092a\u0930 \u0939\u0940 \u0939\u094b\u0924\u093e \u0939\u0948\u0902 \u0907\u0938\u0915\u0947 \u0932\u093f\u090f \u0915\u094b\u0908 Scope \u0915\u093e Rule \u0928\u0939\u0940\u0902 \u0939\u094b\u0924\u093e \u0964 Constant \u0915\u094b \u0939\u092e \u092c\u093e\u0930-\u092c\u093e\u0930 Define \u0928\u0939\u0940\u0902 \u0915\u0930 \u0938\u0915\u0924\u0947 \u0939\u0948\u0902 \u0914\u0930 \u0928 \u0939\u0940 \u0907\u0938\u0947 Blank \u0915\u0930 \u0938\u0915\u0924\u0947 \u0939\u0948\u0902 \u0964 Predefined Constants PHP_VERSION 7.3.12 PHP_MAJOR_VERSION [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1329,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1318","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/selfimagination.in\/tips\/wp-content\/uploads\/2021\/06\/php-constant.jpg?fit=1200%2C628&ssl=1","_links":{"self":[{"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/posts\/1318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/comments?post=1318"}],"version-history":[{"count":13,"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/posts\/1318\/revisions"}],"predecessor-version":[{"id":1333,"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/posts\/1318\/revisions\/1333"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/media\/1329"}],"wp:attachment":[{"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/media?parent=1318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/categories?post=1318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/selfimagination.in\/tips\/wp-json\/wp\/v2\/tags?post=1318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}