php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #8863 function to get constant values by variable name
Submitted: 2001-01-23 12:21 UTC Modified: 2002-01-06 13:00 UTC
From: andrew at andrew dot org Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS: Any
Private report: No CVE-ID: None
 [2001-01-23 12:21 UTC] andrew at andrew dot org
I believe PHP lacks a function to get constant values by
name where the constant's name is stored in a string variable.

What I mean is something like

function get_constant($const_name)
{
	eval ("\$myvar = " . $const_name . ";");
	return $myvar;
}

but I really think that using eval() here is a waste.

Am I missing something?

andrew

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-06 13:00 UTC] jan@php.net
see get_defined_constants
 [2002-01-06 13:00 UTC] jan@php.net
and close it
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 06:01:32 2024 UTC