On Sun, 10 Aug 2003 10:50:03 -0400, you wrote:

>In a language that I used to program in - for development we used to be able
>to make a function that basically just executed everything inbetween:
><hidecode>
>Print "This is html printed" <some programming code> Print "this is more
>code";
></hidecode>
>
>So basically everything in between hidecode and /hidecode is executed the
>same as if the hide code did not exist - except that the hidecode container
>would be something like:
>
>Function hidecode() {
>    if(getenv("remoteaddress")=="myaddress") {
>        %s (all code contained within the tags)
>    }
>}
>
>So - the question is does PHP have some way that I cannot see to do this?
>
>I realize that I could create a function and pass everything in as an
>argument - but that would involve putting everything into variables, and
>overall being just a pain in the ass to add and remove the container.
>
>Is PHP too sophisticated a language to be able to do this easily and
>quickly?  Or am I just missing some form of function that is totally
>obvious?
>
>Finally - yes, I know that I could slap an if tag around it - but that is
>also a big pain in the ass to add and remove each if tag when you go 'live'
>with the change, as opposed to a quick find and replace with a container
>function like this...

Having trouble understanding what you're trying to do.

Maybe you're thinking of eval()

$code = "echo('<p><strong>test</strong></p>')";

hidecode ($code, 'myaddress');

function hidecode($code, $machine) {
  if (getenv ('remoteaddress') == $machine) {
    eval ($code);
  }
}

or a more ugly mechanism, eval with global

function hidecode() {
  global $code;
  if (getenv ('remoteaddress') == 'myaddress') {
    eval ($s);
  }
}

Personally I think functions pushing stuff onto stdout is generally bad
style, but that's just me. I can see how as a debug mechanism this would
make sense.

(The right way to do this is to have live, staging and dev servers. Or at
least live and staging versions of the site on the live server, and dev on
your desktop machine. You don't ever want to be messing with live code
directly, or copying straight from dev to live without testing.)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to