Passing variable value from one if statement to another

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
adkPrasanna
New php-forum User
New php-forum User
Posts: 8
Joined: Tue Feb 02, 2016 12:30 am

Sun Jul 22, 2018 9:01 pm

Is there a way to pass variable and its value from one if..else to another?

if(condition)
{
$var = 3;
}

if(condition)
{
//print the value (i.e 3) of the variable (i.e $var) that is defined in the previous if condition.
}

chorn
php-forum Fan User
php-forum Fan User
Posts: 562
Joined: Fri Apr 01, 2016 2:18 am

Sun Jul 22, 2018 9:43 pm

why do you think $var is not available later?

Post Reply