如何在回声中回声?

时间:2014-02-21 17:48:12

标签: php

以下是我当前代码的副本:

  echo '<td style="word-wrap: break-word;">
     <div><center><a style="text-decoration:none;color:#489FDC;" href="http://local.mysite.com/'.echo basename(__DIR__);.'/'.strtolower(str_replace(" ","-",$row[cities])).'">'.ucwords($row[cities]).'</a></center></div>
   </td>'; 

但我收到此错误,无法弄清楚如何修复它:

[21-Feb-2014 11:46:08 America/Chicago] PHP Parse error:  syntax error, unexpected T_ECHO in /home/username/public_html/local/advertising-company/index.php on line 196

我知道它与代码的这一部分有关:

'.echo basename(__DIR__);.'

我需要更改以解决此问题?

8 个答案:

答案 0 :(得分:1)

删除另一个,

echo '<td style="word-wrap: break-word;">
      <div><center><a style="text-decoration:none;color:#489FDC;" 
      href="http://local.mysite.com/'.basename(__DIR__).
      '/'.strtolower(str_replace(" ","-",$row[cities])).'">'.
      ucwords($row[cities]).'</a></center></div>
      </td>'; 

答案 1 :(得分:1)

  1. 删除第二个echo
  2. 对数组元素使用引号:$row[cities]应为$row['cities']

答案 2 :(得分:0)

你不需要在回声中做回声你可以做

echo '<td style="word-wrap: break-word;">
     <div><center><a style="text-decoration:none;color:#489FDC;" href="http://local.mysite.com/'.basename(__DIR__).'/'.strtolower(str_replace(" ","-",$row[cities])).'">'.ucwords($row[cities]).'</a></center></div>
   </td>'; 

答案 3 :(得分:0)

echo '<td style="word-wrap: break-word;">
 <div><center><a style="text-decoration:none;color:#489FDC;" href="http://local.mysite.com/'.basename(__DIR__).'/'.strtolower(str_replace(" ","-",$row[cities])).'">'.ucwords($row[cities]).'</a></center></div>

';

移动第二个回声,它将显示。

答案 4 :(得分:0)

你不需要调用echo,你只需要连接字符串,即:。

echo '<td style="word-wrap: break-word;">
     <div><center><a style="text-decoration:none;color:#489FDC;" href="http://local.mysite.com/'.basename(__DIR__).'/'.strtolower(str_replace(" ","-",$row[cities])).'">'.ucwords($row[cities]).'</a></center></div>
   </td>'; 

答案 5 :(得分:0)

洛尔。 :)

只需使用方法调用。

echo " SOME STRING " . basename(__DIR__)  . " SOMESTRING "; 

答案 6 :(得分:0)

索引变量应该在单引号内。

echo '<td style="word-wrap: break-word;">
<div>
<center>
<a style="text-decoration:none;color:#489FDC;" href="http://local.mysite.com /"'.basename(__DIR__).'"/'.strtolower(str_replace(" ","-",$row['cities'])).'">'.ucwords($row['cities']).'</a>
</center>
</div>';

答案 7 :(得分:-1)

试试这个......

echo "<td style='word-wrap: break-word;'> <div><center><a style='text-decoration:none;color:#489FDC;' href='http://local.mysite.com/'".basename(__DIR__)."'/'".strtolower(str_replace(" ","-",$row[cities]))."''>'".ucwords($row[cities])."'</a></center></div> </td>";

相关问题