开发者

why this php string giving error?

开发者 https://www.devze.com 2023-01-19 04:03 出处:网络
hi friends why this php string error ? echo\'<div id=\"album_list\"><a href=\"view_gallery/al开发者_如何学JAVAbum_pix/ .$v[\'id\']. \">\' . $i . \' \' . $v[\'album_name\']. \'</a>&l

hi friends why this php string error ?

echo  '<div id="album_list"><a href="view_gallery/al开发者_如何学JAVAbum_pix/ .$v['id']. ">' . $i . ' ' . $v['album_name']. '</a></div>';


You have some missing single quotes.

echo  '<div id="album_list"><a href="view_gallery/album_pix/ .$v['id']. ">' . $i . ' ' . $v['album_name']. '</a></div>';
//                             you need a single quote here ^          ^ and here


You are missing a single-quote after album_pix/ and before the closing bracket.

echo  '<div id="album_list"><a href="view_gallery/album_pix/' .$v['id']. '">' . $i . ' ' . $v['album_name']. '</a></div>';


  • Single quote the string with the double quotes and attributes
  • Single space and concatenate with the period .
  • Change $var['key'] to $var, or $var["key"]

I'd change your variable names to reduce the confusion. As someone said above syntax highlighting will turn all the strings one color, and the variables another. Stack Overflow even displays code as such.

<?php

$v_id         = $v['id'];
$v_album_name = $v['album_name'];

echo  '<div id="album_list"><a href="view_gallery/album_pix/' . $v_id . '">' . $i . ' ' . $v_album_name . '</a></div>';

?>
0

精彩评论

暂无评论...
验证码 换一张
取 消