laravel如果声明不起作用

时间:2016-12-21 13:21:39

标签: php laravel if-statement

任何人都可以告诉我为什么当结果相等时它回应了响应,但是当结果为假时它会显示一个空白页面。我确定我在某个地方出了问题。

if(isset($_GET['EX1']) && $_GET['EX2'] != ""){

        $Email = $_GET['EX1'];
        $Password = $_GET['EX2'];

        $userDetails = DB::table('applicants')
            ->where('Email', '=', $Email)
            ->where('Password','=', $Password)
            ->get();

        if($Email = $userDetails[0]->Email && $Password = $userDetails[0]->Password){

            echo 'Both are the same ';

        }else{

            echo 'Not the same';

        }
    }

2 个答案:

答案 0 :(得分:2)

if($Email = $userDetails[0]->Email && $Password = $userDetails[0]->Password){

应该是

if($Email == $userDetails[0]->Email && $Password == $userDetails[0]->Password){

您正在使用作业=而不是比较==,而true将始终返回public class PROJECT { [Display(Name = "Project No.")] public string PROJECT_NO { get; set; } [Display(Name = "Title")] [DataType(DataType.MultilineText)] [Required] public string TITLE { get; set; } [Display(Name = "Description")] [DataType(DataType.MultilineText)] public string DESCRIPTION { get; set; } [Display(Name = "Remarks")] public string REMARKS { get; set; } }

答案 1 :(得分:0)

这样可行!

if(.... = ....)

顺便说一句,您需要将if(.... == ....)更改为===用于分配值,echo "person.name,person-age`r`njohn,27" | ConvertFrom-Csv | Out-GridView 用于比较值。

希望这有效!