Skip to content

Tag: global

How to json_encode $GLOBALS?

I’m trying to debug a PHP application, and as a section of the debug process, I passed print_r($GLOBALS) through the AJAX request to my browser. However, I’d prefer to see it in native JSON form because it comes out better in the browser. I’m trying to use the following snippet of code: but …

Alternative for define array php

I’m looking for an alternative for define(‘name’, array) as using an array in define gives me this error: Constants may only evaluate to scalar values in … The array I’m mentioning contains strings only. Answer From php.net… The value of the constant; only scalar and null v…

Global variable is not working as expected in PHP

I’m trying to make my own simple framework in PHP. It’s going OK but I’m running into a problem. I redirect everything back to my index.php, and from there I start loading classes and functions. I split up the url into segments, which works fine, until I want to use the segments in a class. …