1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development $GLOBALS and custom tags

Discussion in 'Software' started by ManStrike, 2 Jul 2006.

  1. ManStrike

    ManStrike What's a Dremel?

    Joined:
    29 Jan 2002
    Posts:
    58
    Likes Received:
    0
    I’m working on building custom tags for php, so far all has been going well. I have made a set and a get tag.

    input
    PHP:
    <rmpw:set var="$bar">Hello World</rmpw:set>
    <
    html>
    <
    head>
    <
    title><rmpw:get var="$bar"/></title>
    <
    rmpw:set var="$bar">Some new text</rmpw:set>
    </
    head>
    <
    body>
    <
    p><rmpw:get var="$bar"/></p>
    </
    body>
    A global variable called $bar is created with the rmpw:set which can then be accessed by the rmpw:get. This all works fine, however if I try and change the value of $bar with some new text I cant seem to replace it.

    output
    Code:
    <html>
    <head>
    <title>Hello World</title>
    </head>
    <body>
    <p>Hello World</ p> <!—should be ‘Some new text’ -->
    </body>
    
    I’m using $GLOBALS to store the variables but it only seems to effect it locally and I’m all so using ob_start which might be effecting it.

    PHP:
    function globalSet($variable$value) {
        
    $add = array($variable$value);         
        for (
    $i=0$i count($GLOBALS); $i++) {
            if (
    $GLOBALS[$i][0] == $variable) {
                unset(
    $GLOBALS[$i]);                    
                break;
            }
        }    
        
    array_push($GLOBALS$add);
    }

    function 
    globalGet($variable) {
        for (
    $i=0$i count($GLOBALS); $i++) {
            if (
    $GLOBALS[$i][0] == $variable) {
                return 
    $GLOBALS[$i][1];
            }
        }
    }
    any suggesting on why I can’t update my $GLOBALS would be appreciated
     

Share This Page