PHP Classes

Encapsulate PHP Constants in Class: Encapsulate several constants in the same class

Recommend this page to a friend!
  Info   View files Example   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 178 This week: 1All time: 8,733 This week: 560Up
Version License PHP version Categories
abstractconstants 1.0GNU General Publi...5PHP 5, Language
Description 

Author

This class can encapsulate several constants in the same class.

It provides a base class that can store constant values in class variable.

Applications should extend this class to allow retrieving all constants defined in an class as an array.

Innovation Award
PHP Programming Innovation award nominee
April 2019
Number 9
Many classes need to define constant values, so they can have meaningful names for the values that they need to use.

This package makes that task easier by providing a base class that assigns values to constants from an array defined in a sub-class that needs to use those constants.

Manuel Lemos
Picture of Steven Hoyt
  Performance   Level  
Name: Steven Hoyt <contact>
Classes: 3 packages by
Country: United States United States
Age: ???
All time rank: 3488466 in United States United States
Week rank: 411 Up48 in United States United States Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php
////////////////////////////////////////////////////////////
// required files
require_once 'application.class.php';
////////////////////////////////////////////////////////////
// main script
echo '<pre style="font:11px courier new; text-align:left;">' . print_r(array(Application::$paths::get(), Application::$roles::get()), true) . "</pre>\r\n";


  Files folder image Files  
File Role Description
Accessible without login Plain text file test.php Example Test script (demonstrate usage)
Plain text file application.class.php Class ApplicationClass (example caller class)
Plain text file paths.class.php Class Paths (example extending class)
Plain text file roles.class.php Class Roles (example extending class)
Plain text file abstract.constants.class.php Class AbstractConstants
Accessible without login Plain text file test.output.txt Output Sample output

 Version Control Unique User Downloads Download Rankings  
 0%
Total:178
This week:1
All time:8,733
This week:560Up