MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

PHP Programing language

Constants in PHP
Previous Home Next

Constants

A constant is an identifier for a simple value. A constant value cannot be modified during the execution of the script. By default a constant is case-sensitive. It can be defined by using define() function or by using keyword const outside a class definition.

<?php
define("Student_name""Ankur");
echo Student_name;
?>

Output:

Ankur

 

Valid and Invalid constant names:

<?php  
//Valid constants name  
define("student_name""Ankur");  
define("class""V");

//Invalid constants name  
define("2NO_OF_STUDENTS", 60);  
define("__Total__", "total value"); 
?>

PHP Magic constants:

PHP provides a large number of predefined constants to any script which it runs.

SNo. Name Description
1 __LINE__ The current line number of the file.
2 __FILE__ The full path and filename of the file with symlinks resolved. If used inside an include, the name of the included file is returned.
3 __CLASS__ The class name. The class name includes the namespace it was declared in (e.g. Foo\Bar). __CLASS__ works also in traits. When used in a trait method, __CLASS__ is the name of the class the trait is used in.
4 __TRAIT__ The trait name. The trait name includes the namespace it was declared in (e.g. Foo\Bar).
5 __METHOD__ The class method name.
6 __FUNCTION__ The function name.
7 __NAMESPACE__ The name of the current namespace.
8 __DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless it is the root directory.
Previous Home Next