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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrew at andrew dot org
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 08:01:30 2025 UTC