Diana
Diana Parker
shared a link
011e11c6a03fede2690d29d7982e9ab0
PHP Magic Constant examle - Phptpoint.com — phptpoint.com

PHP Magic Constant 
 
 There are a number of predefined constants available to your scripts. We will use these constants as we need them; there's a sample:
 
 PHP: Magic Constant 
 
 
 
 
 PHP Magic Constant
 
 
 __LINE__
 The current line number of the file.
 
 
 __FILE__
 The full path and filename of the file.
 
 
 __FUNCTION__
 The function name
 
 
 __CLASS__
 The class name
 
 
 __METHOD__
 The class method name
 
 
 PHP_VERSION
 The PHP version
 
 
 PHP_INT_MAX
 The PHP integer value limit
 
 
 
 
 __LINE__ 
 
 The current line number of the file.
 
 
 
 <?php
 
 echo "The Line number : ". __LINE__;
 
 ?>
 
 
 
 
 Output The Line number : 2
 
 __FILE__ 
 
 The full path and filename of the file.
 
 
 
 <?php
 
 echo "Your file name :". __FILE__;
 
 ?>
 
 
 
 
 Output Your file name : C:xampplitehtdocsmagic_constantfile.php
 
 __FUNCTION__,     __CLASS__,     __METHOD__ 
 
 The function name The class name The class method name
 
 
 
 <?php
 
 class demo
 
 {
 
 function test()
 
 {
 
 echo "Function of demo class : ". __FUNCTION__ ."<br/>";
 
 }
 
 function testme()
 
 {
 
 echo "Method of demo class : ". __METHOD__ ."<br/>";
 
 echo "Class : ". __CLASS__;
 
 }
 
 }
 
 $object=new demo();
 
 $object->test();
 
 $object->testme();
 
 ?>
 
 
 
 
 Output Function of demo class : test Method of demo class : demo::testme Class : demo
 
 PHP_VERSION 
 
 The PHP version
 
 
 
 <?php
 
 echo "Current PHP Version you are using : ".PHP_VERSION;
 
 ?>
 
 
 
 Output Current PHP Version you are using : 5.3.1
 
 PHP_INT_MAX 
 
 The PHP integer value limit
 
 
 
 <?php
 
 echo "Integer Maximum Value : ".PHP_INT_MAX;
 
 ?>
 
 
 
 
 Output Integer Maximum Value : 2147483647

Read More



This site uses cookies to give the best and personalised experience. By continuing to browse the site you are agreeing to our use of cookies. Find out more here.

Sign Up or Login

Invalid username or password
Not yet on CircleMe? Join now
Please input a email
Please input a valid email
Max 50 characters
Email already in use
{{email_serverError}}
Please input a username
Min 3 characters
Max 20 characters
Please use only A-Z, 0-9 and "_"
Username is taken
Please input a password
Min 6 characters
Max 20 characters
By clicking the icons, you agree to CircleMe terms & conditions
Already have an account? Login Now