note 61756 deleted from language.variables.scope by cmb

From: Date: Sun, 27 Oct 2019 08:30:41 +0000
Subject: note 61756 deleted from language.variables.scope by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212781@lists.php.net to get a copy of this message
Note Submitter: franp at free dot fr ---- If you want to access a table row using $GLOBALS, you must do it outside string delimiters or using curl braces : <?php $siteParams["siteName"] = "myweb"; function foo() { $table = $GLOBALS["siteParams"]["siteName"]."articles"; // OK echo $table; // output "mywebarticles" $table = "{$GLOBALS["siteParams"]["siteName"]}articles"; // OK echo $table; // output "mywebarticles" $table = "$GLOBALS[siteParams][siteName]articles"; // Not OK echo $table; // output "Array[siteName]article" $result = mysql_query("UPDATE $table ..."); } ?> Or use global : <?php function foo() { global $siteParams; $table = "$siteParams[siteName]articles"; // OK echo $table; // output "mywebarticles" $result = mysql_query("UPDATE $table ..."); } ?>

« previous php.notes (#212781) next »