<?php
$connection = mysql_connect( "localhost", "root", "icecream" ) ;
mysql_select_db( "winestore", $connection ) ;
$result = mysql_query( "SELECT surname, firstname, city FROM customer;" ) ;
while( $row = mysql_fetch_array( $result ) )
{
print_r( "$row['surname']" ) ;
}
?>
很简单的一段代码,但是print_r那一行出错了,如果把这一行换成print_r("{$row['surname']}")就没问题了,我很纳闷,不加尖括号从语法上来讲有什么错吗?
$connection = mysql_connect( "localhost", "root", "icecream" ) ;
mysql_select_db( "winestore", $connection ) ;
$result = mysql_query( "SELECT surname, firstname, city FROM customer;" ) ;
while( $row = mysql_fetch_array( $result ) )
{
print_r( "$row['surname']" ) ;
}
?>
很简单的一段代码,但是print_r那一行出错了,如果把这一行换成print_r("{$row['surname']}")就没问题了,我很纳闷,不加尖括号从语法上来讲有什么错吗?
print_r( $row['surname']) ;
试一下你用print_r( "$row['surname']" ) ;,双引号被认为是字符串了
如果是数组才需要 print_r 另外如楼上