Welcome Guest, Not a member yet? Register   Sign In
String operator ".=" trouble
#1

[eluser]DIMM[/eluser]
Hello! I have a small problem which I can not settle.
I use .= operator in recursive function which builds a navigation from a database. But it constantly say "Message: Undefined variable: menu" when i use $menu.='addsubstring'.
who can say in what problem?
#2

[eluser]devbro[/eluser]
the problem is that your $menu is not defined yet. do something like this:


function a()
{
static $menu = '';

$menu .= 'your sub string';
}

for more info on static goto: (example 5)
http://ca2.php.net/global
#3

[eluser]RS71[/eluser]
Yea. You're appending to something that doesn't exist.

Code:
$menu  = 'Hello';
$menu .= ' World';

echo $menu;
//Hello World
#4

[eluser]Colin Williams[/eluser]
That should just be a "Notice" level message. Some people choose to ignore notices.
#5

[eluser]DIMM[/eluser]
Ok thank you!




Theme © iAndrew 2016 - Forum software by © MyBB