Toggle navigation
Dashboard
Dashboard Tracker
Add / Edit My Forums
System Announcements
Discussion
Active Thread Feed
Top Threads Today
Top Threads This Week
Top Threads Library
Go!
View All
View All
Login
Logout
Home
Forums Index
Server Side
/
PHP Server Side Scripting
12:26 pm May 21, 2026
This page requires javascript.
Forum Moderators:
coopster
Message Too Old, No Replies
if $var1=1 then $var2=4
skoff
Msg#:4300843
12:55 am on Apr 20, 2011
(gmt 0)
Hi everyone its me again!
I was wondering how could I do that?
$var1=1;
$var2=2;
if ($var1=1) then $var2=4
it would not =2 anymore? Anyway to do this? I may be not clear but I dont know how to explain it differently..
Thanks
Mahabub
Msg#:4301136
8:40 am on Apr 20, 2011
(gmt 0)
I hope it will work
$var1=1;
$var2=2;
$var2 = ($var1 == 1 ) ? 4 : $var2;
mbabuskov
Msg#:4301207
11:42 am on Apr 20, 2011
(gmt 0)
$var = 1, assigns 1 to $var and returns it (1). Therefore
if ($var = 1)
is the same as:
$var = 1;
if (1)
jecasc
Msg#:4301223
12:05 pm on Apr 20, 2011
(gmt 0)
Keep in mind that:
if ($var1=1)
is not the same as
if ($var1==1)
I am not quite sure what you are doing but if I understand it correctly you want:
if ($var1 == 1) $var2 = 4;
skoff
Msg#:4301259
1:34 pm on Apr 20, 2011
(gmt 0)
ok so i'll try to be more specific!
i have declared two variables
$var1=rand(0,1);
$var2=rand(0,1);
And what i want to do is
if $var1=0 then $var2 can = 0 or 1
But if $var1=1 $var2 can just = 0
i know it's not really what i explained first but thats what i need to know how to do!
Thanks! ;)
jecasc
Msg#:4301262
1:37 pm on Apr 20, 2011
(gmt 0)
$var1=rand(0,1);
if ($var1==0) $var2=rand(0,1);
else $var2=0;
or
$var1=rand(0,1);
$var2=rand(0,1);
if ($var1==1) $var2=0;
skoff
Msg#:4301266
1:45 pm on Apr 20, 2011
(gmt 0)
damn! that was fast! :O thanks a lot :D
Join The Conversation
Register
For Free! -
Become a
Pro Member
!
See forum categories
-
Enter the Forum
Moderators and Top Contributors
Moderator List
| Top Contributors:
This Week
,
This Month
,
Apr
,
Mar
,
Archive
,
Top 100 All Time
,
Top Voted Members
Hot Threads This Week
May 2026 Google Search Observations
AdSense Earnings and Observations - May 2026
AI visibility audit
Adsense / Personal Manager / Support
Hacker spoofing as GoogleBot
Page indexed but live url test gets 500 error
Link collaboration strategies
in case you missed it .
Microsoft, AS8075. Google, AS396982.
Bad actor claiming to be OpenAi
Home
Forums Index
Server Side
/
PHP Server Side Scripting
12:26 pm May 21, 2026