How to revoke an expression

As an echo expression in an if condition.

Please refer to the code

<?php
session_start();
require_once 'class.user.php';
$user_home = new USER();

if(!$user_home->is_logged_in())
{
    $user_home->redirect('<?php echo $web ?>index.php');
}

$stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmt->execute(array(":uid"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);

?>

      

Please fix it

$user_home->redirect('<?php echo $web ?>index.php');

      

I want to echo $ web .

+3


source to share


2 answers


In PHP code, you didn't need an echo variable. You are trying to concatenate a string here using the value in your $ web variable. Therefore you can use .

to concatenate strings.



 $user_home->redirect($web.'index.php');

      

+3


source


Using

<?php
session_start();
require_once 'class.user.php';
$user_home = new USER();

if(!$user_home->is_logged_in())
{
    $user_home->redirect($web.'index.php');
}

$stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmt->execute(array(":uid"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);

?>

      



You can also refer to PHP Concatenation

+1


source







All Articles