Forum Moderators: coopster

Message Too Old, No Replies

Destroying defined vars

         

ahmedtheking

4:37 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it possible to destroy (unset()) defined (define()) vars? Or update them?

jatar_k

4:57 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't see why not

ahmedtheking

5:32 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I get this error:

Parse error: parse error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in /Applications/xampp/htdocs/sites/firestar/inc/buildfiles/config.cfg.php on line 23

And here's the code:


<?php
// this is the main config file!
// make sure that this is out of public_html!

// localhost vars
define(LPATH,"/sites/firestar");
define(LHOST,"1");
//define(LPATH,"");

// run a security check
if (!strstr($_SERVER['HTTP_HOST'],"...") && LHOST!= "1") {
// send to site if not from the site!
header("Location: http://...".$_SERVER['REQUEST_URI']);
}

// define goto
define(GOTO,$_GET['goto']);

// define get (for pop ups, sandbox, etc...)
define(GET,$_GET['get']);

// define id (for news, etc...)
define(ID,$_GET['id']);

// set cookies
// set no more intro cookie
if ($_SERVER['QUERY_STRING'] == "nomoreintro") {
// set the cookie
setcookie("intro","no",time()+"259200");

// take to homepage
unset(GOTO); define(GOTO,"index");
}

I think that error is telling me that I can't unset(GOTO)!

jatar_k

6:03 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



that code works perfectly for me, no parse errors

try this thread
[webmasterworld.com...]

coopster

10:35 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That's odd, jk, you should be getting parse errors.

ahmedtheking, once a constant is defined, it can never be changed or undefined, nor can it be unset(). unset() is for variables and a CONSTANT [php.net] is not a variable.

jatar_k

5:07 am on Apr 6, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



weird, have to retry that later. The host I was using throws errors so not sure what is up.

thankfully, coop got it straight. ;)