Php 访问函数内的查询变量

Php 访问函数内的查询变量,php,function,Php,Function,好的-我能够将分配给变量$myfile的字符串传递到函数中。如果可以更好,请提供反馈-学习PHP <?php $myfile = $row_rs_recordview['headstone']; echo "$myfile"; // verify the file name function readGPSinfoEXIF($myfile) { global $myfile; $exif= exif_read_data("headstone/".$myfile, 0, true

好的-我能够将分配给变量$myfile的字符串传递到函数中。如果可以更好,请提供反馈-学习PHP

<?php
$myfile = $row_rs_recordview['headstone'];
echo "$myfile"; // verify the file name
function readGPSinfoEXIF($myfile)
{    
 global $myfile;
 $exif= exif_read_data("headstone/".$myfile, 0, true); //
 if(!$exif || $exif['GPS']['GPSLatitude'] == '') //Determines if the
                          //geolocation data exists in the EXIF data
 {
      return false; //no GPS Data found
      echo "No GPS DATA in EXIF METADATA";
 }
?>

感谢您的真知灼见


谢谢

您不能直接访问函数中的全局变量

//add global before variable declaration like this
function fun(){  
   global $row_rsUpdate['headstone'];
}

将变量作为参数传递给函数?上面的代码段没有语法错误,您能告诉我们语法错误吗?复制并粘贴语法错误描述。谢谢Aqib。我用了一种稍微不同的方法。