【问题标题】:Strict Standards: Only variables should be passed by reference in please严格标准:请仅通过引用传递变量
【发布时间】:2017-03-01 10:01:27
【问题描述】:

严格的标准:只有变量应该通过引用传递

if(isset($_FILES['image'])){
  $errors= array();
  $file_name = $_FILES['image']['name'];
  $file_size =$_FILES['image']['size'];
  $file_tmp =$_FILES['image']['tmp_name'];
  $file_type=$_FILES['image']['type'];
  $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));

  $expensions= array("jpeg","jpg","png","docx","pdf");

  if(in_array($file_ext,$expensions)=== false){
     $errors="<div align='center'><font color='red'>extension not allowed, please choose a JPEG or PNG file.</font></div>";
  }

【问题讨论】:

标签: php


【解决方案1】:

内置的end 需要一个通过引用传递的数组。所以传入的数组必须是一个变量。

  $var = explode('.',$_FILES['image']['name']);
  $file_ext=strtolower(end($var));

This means you must pass it a real variable and not a function returning an array

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2013-12-28
    • 2012-10-25
    相关资源
    最近更新 更多