faqts : Computers : Programming : Languages : PHP : kms : Functions

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 39 people (28%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

How do I set a global variable variable in a function?

Jun 8th, 1999 07:00
Nathan Wallace, Frank M. Kromann


You have to globalize both variables.
  
<?php

$test = "test1";

function tt() {
 global $test;
 global $$test;

 print("$$test\n");
}

$test1 = "jhkjh";

tt();

?>