Useful PHP Predefined Constants defined by the PHP core.

PHP_VERSION - Contains a string with the current PHP version.
echo PHP_VERSION; // 5.5.3
PHP_MAXPATHLEN - The maximum length of filenames (including path) supported by this build of PHP.
echo PHP_MAXPATHLEN; // 260
PHP_OS - Contains a string that can be used to detect the operatig system PHP is running on. Some posible values:
CYGWIN_NT-5.1, Darwin (for Mac Os X), FreeBSD, HP-UX, IRIX64, Linux, NetBSD, OpenBSD, SunOS, Unix, WIN32, WINNT (for Windows NT), Windows, CYGWIN_NT-5.1, IRIX64, SunOS, HP-UX, OpenBSD.
echo PHP_OS; // WINNT
PHP_EOL - The correct 'End Of Line' symbol for the platform on which PHP is running on. Useful to add new lines in strings.
echo ''. PHP_EOL .'Next line';
__LINE__ - The current line number of the file.
// test
echo __LINE__;       // 3
__FILE__ - The full path and filename of the current php file. If used inside an include, the name of the included file is returned.
echo __FILE__; // D:\server\www\file.php
__DIR__ - The directory of the current php file. If used inside an include, the directory of the included file is returned. This is equivalent to: dirname(__FILE__). Not have a trailing slash unless it is the root directory.
echo __DIR__; // D:\server\www
__FUNCTION__ - The function name in which this constant is accessed.
function someName() {
  echo __FUNCTION__;
someName();      // someName
__CLASS__ - Returns the class name as it was declared (case-sensitive).
class someClass {
  public function className() {
    return __CLASS__;

$obj = new someClass();
echo $obj->className();      // someClass
__METHOD__ - Returns the class method name as it was declared, including the class name (case-sensitive).
class someClass {
  public function someMethod() {
    return __METHOD__;

$obj = new someClass();
echo $obj->someMethod();      // someClass::someMethod

Daily Test with Code Example

Which tag is used to add lists into <ul> and <ol> elements?
<dt> <dd> <li>
Which value of the "display" property creates a block box for the content and ads a bullet marker?
block list-item inline-block
.some_class {
  display: list-item;
Which instruction converts a JavaScript object into a JSON string.
JSON.parse() JSON.stringify eval()
var obj = {
 "courses": ["php", "javascript", "ajax"]
var jsonstr = JSON.stringify(obj);
alert(jsonstr);    // {"courses":["php","javascript","ajax"]}
Indicate the PHP class used to work with HTML and XML content in PHP.
stdClass PDO DOMDocument
$strhtml = '<body><div id="dv1"></div></body>';
$dochtml = new DOMDocument();
$elm = $dochtml->getElementById("dv1");
echo $elm->nodeValue;    //
PHP Predefined Constants

Last accessed pages

  1. Get the value of the selected /checked checkboxes in a form (41519)
  2. jQuery Drag and Drop Rows between two similar Tables (8474)
  3. JQZoom Image Magnifier (10575)
  4. Contact page - CoursesWeb (22089)
  5. Tabs effect with CSS (22791)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (1761)
  2. Making DIV Contents Scroll Horizontally, with multiple Div`s inside (1643)
  3. Contact page - CoursesWeb (1589)
  4. Tabs effect with CSS (1586)
  5. Insert, Select and Update NULL value in MySQL (1049)