Jump to content

Why does this not work??


homchz

Recommended Posts

[code]
class navigation
{
    var $u_links = array(
                    'Home'    => 'http://www.domain.com',
                    'Profile' => '?page=profile&uid=$u_id',
                    'Search'  => '?page=search');

    function navigation()
    {
         
    }
    
    function get_nav($u_id)
    {        
        foreach($this->u_links as $title => $url)
        {
            print "<a href=\"$url\">$title</a><br/>";
        }
    }
}

[/code]

The profile links does not recognize $u_id it only prints the literal $u_id.

Is this not possible??
Link to comment
https://forums.phpfreaks.com/topic/11285-why-does-this-not-work/
Share on other sites

This should work:
[code]<?php
    var $u_links = array(
                    'Home'    => 'http://www.domain.com',
                    'Profile' => "?page=profile&uid=$u_id",
                    'Search'  => '?page=search');
?>[/code]
or
[code]<?php
    var $u_links = array(
                    'Home'    => 'http://www.domain.com',
                    'Profile' => '?page=profile&uid=' . $u_id,
                    'Search'  => '?page=search');
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/11285-why-does-this-not-work/#findComment-42276
Share on other sites

[!--quoteo(post=380466:date=Jun 5 2006, 11:02 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 5 2006, 11:02 PM) [snapback]380466[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I'll advise you that it's probably not going to work as expected.

The variable in the array will be extended but it will have an empty value.
[/quote]

Yes I tried both methods before posting here and actually recieved errors. I got around this by passing a session variable and not URL variable.

Thanks for the advice though,

Josh
Link to comment
https://forums.phpfreaks.com/topic/11285-why-does-this-not-work/#findComment-42356
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.