Comparison Operators 'equal' is not working [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am validating a condition for
$time = $user['time_send'];
$chk_date = date('Y-m-d H:i');
var_dump($time == $chk_date);
But I am getting bool(false) as output.

$time = '2014-03-7 15:14';
$chk_date = '2014-03-07 15:14';
if(strtotime($time) == strtotime($chk_date)){
echo 'hola';
}else{
echo 'hello';
}

Related

how to add string to variable in php? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
i just need on small info i want just add '#' to one variable and and put add thing into one variable. i am adding small php code to here please suggest me.
<?php
$email34 = $row['email'];
$rem = '#gmail.com';
$trim_email = str_replace($rem ,'', $email34);
$tag_name ="#".$trim_emial.;
echo $tag_name;
?>
but i am getting only # as output;
but my out should be "#mahesh1" if any have idea about this code please help me. thank you advanced.
there is so much spelling mistakes in the variables... try below given code
<?php $email34 = $row['email'];
$rem = '#gmail.com';
$trim_email = str_replace($rem ,'', $email34);
$tag_name ="#".$trim_email;
echo $tag_name;
?>

If-statement string strange comparaison [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I've probably miss something but I realy don't understand that :
if(trim($_GET[$slug]) == trim($cat->$slug)) {
$selected = 'selected';
}
else {
$selected = '';
}
var_dump(trim($_GET[$slug]));
var_dump(trim($cat->slug));
var_dump($selected);
Show :
string(8) "albanais"
string(8) "albanais"
string(0) ""
Should be using $cat->slug inside the if statement rather than $cat->$slug

If a variable is something and another variable is something else do, PHP [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm doing some PHP traning, and wanted to make my own copy of "Rock, Paper and Scissors" and then I'd like to compare the results from the user and the computer, and I tried with this code:"
if($choice = 'Rock' and $pcSelect == 'Scissors'){
echo "You win!";
}
Plz help me,
Magn0053
You are assigning 'Rock' to $choice with =. You need to test equality with == like in the second conditional.
Use && instead of and in your if
if($choice == 'Rock' && $pcSelect == 'Scissors'){
echo "You win!";
}

PHP console does not echo [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Okay this really strange or I am missing something. When I run this very simmple PHP script on cmd I get the expected output which is 0. but when I uncomment the last two lines of code. . .nothing is displayed.
<?php
$test1 = 0;
echo $test1;
$test2 = 0;
#$test1_weight = 0:
#$test2_weight = 0;
?>
Is there some rule against declaring variables after an echo statement?
$test1_weight = 0:
--> change ":" to ";"
No there is no rule against declaring variables after an echo statement

Why elseif condition doesn't work? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
<?php
$datetime=date("d-m-y");
$date1=date("d")+1;
$datetime1=date("$date1-m-y ");
$date1=$date1+1;
$datetime2=date("$date1-m-y ");
$date1=$date1+1;
$datetime3=date("$date1-m-y ");
echo $_POST['date1'];
echo $datetime1;
if($_POST['date1']==$datetime1)
{
header("location:bus2.php");
}
?>
here if condition doesn't work even though echo $_POST['date1']; and echo $datetime1; shows the same result.
The values are NOT the same:
$datetime1=date("$date1-m-y ");
^--this space makes all the difference:
$_POST['date1'] = '14-02-2014';
$datetime1 = '14-02-2014 ';
^--- spot the difference

Categories