How to read a constant's value defined in .inc file in cakephp
I am a newbie to cakephp and recently i am given a task to implement memcache into the current features of my app as a part of Optimization. I implemented it and its working fine but now I want to update my memcache key,value pair through a cron. So I made one function :
function mcache($client_id,$keyword_id,$function)
{
$this->$function($client_id,$keyword_id);
}
I want to call this function thru cron scheduler and in the $function parameter I want to give a pass a string which I have defined in my define.inc file. Its structure is like dis:
define ("HEAT_MAP","getHeatmapData");
define ("AGE_DEMOGRA开发者_如何转开发PHICS","getAgeDemographicsData");
define ("GENDER_DEMOGRAPHICS","getGenderDemographicsData");
Here I want to pass "HEAT_MAP" to my function mcache as a parameter in $function and I want to read the corresponding value so that it can call the function getHeatmapData.
When I am doing it like this its giving me "HEAT_MAP" not getHeatMapData. I know its bit confusing but if u want some info plz lemme know. Any Ideas???
As documentation explains, you should define constants in app/core/bootstrap.php
e.g.
// In app/core/bootstrap.php
define('YOURCONSTANT', 'Some value here');
// In view
echo YOURCONSTANT;
to read the value of a constant use the constant()
function
define("FOO", "BAR");
$z = "FOO";
echo constant($z); // "BAR"
精彩评论