I am working on a PHP script which I was cleaning up after the code was working. To make code more readable and easy to fix for future, I tried to move all the regularly used variables to constants.
One such variable value was "http://api.io/url/" which I moved to define and assigned to URL_PREFIX
define("URL_PREFIX" , "http://api.io/url/");
define("FILE_PREFIX" , "http://api.io/files/");
This script worked with the changes. However it started failing suddenly, and on debugging I realized, the place where I am calling URL_PREFIX was assigning the value as "URL_PREFIX" instead of "http://api.io/url/"
$apiUrl = URL_PREFIX . "" . $scope; **[FAILS]**
$apiUrl = "http://api.io/url/" . "" . $scope; **[WORKS]**
Am I missing something up here ?
URL_PREFIXto the string'URL_PREFIX'if it's not defined. So that's what's going on. We'd need to know the code path in between your define and the place it's now not defined to know what's going wrong, but a missingrequireor something would normally be the problem.echo URL_PREFIXjust after thedefine? Does it work? What about if you do it just before the$apiURL = ...? Does it still work? If the answer to these two questions is "yes" and "no" respectively, your problem must be in the code you're not showing us.