Re: syntax problem

From: Date: Wed, 09 Aug 2000 09:16:19 +0000
Subject: Re: syntax problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-10876@lists.php.net to get a copy of this message
source@virtuagency.com wrote:
Hello, Here is my sytax problem. This doesn't work. I get an error with $myartgr->$1[ArtGruppe] : echo "<ahref='$Basis_R/untergruppe.php3?AGN=$myartgr>ArtGrNr&Kennung=$Kennung'>
$myartgr->$l[ArtGruppe]</a><br>";
.............................................^^^^^^^^^^^^ You probably meant $myartgr->ArtGrNr above.
This works : $str=$myartgr->$l[ArtGruppe]; echo "<a href='$Basis_R/untergruppe.php3?AGN=$myartgr->ArtGrNr&Kennung=$Kennung'>$str </a><br>"; and with one more echo it works also.
Why not just do this? $str = $myartgr->$l[ArtGruppe]; echo "<a href='$Basis_R/untergruppe.php3?"; echo "AGN=$myartgr->ArtGrNr&Kennung=$Kennung'>$str</a><br>"; or this: $str = $myartgr->$l[ArtGruppe]; echo "<a href='$Basis_R/untergruppe.php3?"
     . "AGN=$myartgr->ArtGrNr&Kennung=$Kennung'>$str</a><br>";
Although this should work: $str = $myartgr->$l[ArtGruppe]; echo " <a href='$Basis_R/untergruppe.php3? AGN=$myartgr->ArtGrNr&Kennung=$Kennung'>$str</a><br> "; As well as this: $str = $myartgr->$l[ArtGruppe]; ?> <a href='<? echo $Basis_R; ?>/untergruppe.php3? AGN=<? echo $myartgr->ArtGrNr; ?>&Kennung= <? echo $Kennung; ?>'><? echo $str; ?></a><br> <? It just depends on how ugly you want it. :-) I realize you're trying to beat backslashitis, but you need to use double quotes with HTML (although single quotes will probably work fine).
Isn't there any other way to write this in one line i.e. with {} or ... ? Thanks
You _should_ be able to write it on one line without any problem. See if this works: <?php $a = $Basis_R; $b = $myartgr->ArtGrNr; $c = $Kennung; $d = $myartgr->$l[ArtGruppe]; print "<ahref=\"$a/untergruppe.php3?AGN=$b&Kennung=$c\">$d</a><br>"; ?>

« previous php.general (#10876) next »