Reputation: 91
I'd like to preface the built-in PHP functions in my code with "php_" to simply make it easier to identify them as such, and to do so without using a 3rd party add-on. So my first attempt at it was this:
<?php
define('php_date_default_timezone_set', 'date_default_timezone_set');
define('php_date', 'date');
php_date_default_timezone_set('America/Los_Angeles');
echo php_date('l, F j, Y \a\t g:i:s a');
?>
This causes the error,
PHP Fatal error: Call to undefined function php_date
One [ugly] way to do this that actually works is:
<?php
define('php_', '');
php_.date_default_timezone_set('America/Los_Angeles');
echo php_.date('l, F j, Y \a\t g:i:s a');
?>
I suspect there is more than one way to do it; how would you do it?
Upvotes: 0
Views: 200
Reputation: 3263
You could wrap the functions in your own custom functions. Mark Ormston's method is better though.
function php_date_default_timezone_set($timezone)
{
date_default_timezone_set($timezone);
}
function php_date($date)
{
date($date);
}
Upvotes: 1