PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
bruceg
Forum Contributor
Posts: 174 Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:
Post
by bruceg » Fri Apr 15, 2005 1:01 pm
I get an error on line 9 of the below code (the line beginning with $str)
'parse error, unexpected T_Variable'.
I'm pretty new to PHP programming and not sure what's wrong with that line...any suggestions?
Code: Select all
<?php
function breadcrumb_nav($basename = "Home") {
global $PHP_SELF, $bc_site, $bc_label;
$site = $bc_site;
$return_str = "<A HREF=/"//">$basename</A>";
$str = substr(dirname($PHP_SELF), 1);
$arr = split('/', $str);
$num = count($arr);
if ($num > 1){
foreach($arr as $val) {
$return_str .= ' > <a href="'.$site.$val.'/">'.$bc_label[$val].'</a>';
$site .= $val.'/';
}
} elseif($num == 1) {
$arr = $str;
$return_str .= ' > <a href="'.$bc_site.$arr.'/">'.$bc_label[$arr].'</a>';
}
return $return_str;
}
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Apr 15, 2005 1:54 pm
if you want a double quote in a double quote string, it must be escaped. i.e.Code: Select all
"e;this is a double quote string with some \"e;double quotes\"e; in it"e;;
line 8 also has //, which is a single line comment in php. So the line isn't being terminated by the semicolon. i.e. php sees the followingCode: Select all
$return_str = "e;<A HREF=/"e;
$str = substr(dirname($PHP_SELF), 1);