PDA

View Full Version : PHP - A condition into a condition


Scanu
09-11-2011, 08:38 PM
Hi everywone is me again, I have this condition

if (condition1 OR condition2)
{
Do some php code
}

I want to add "or condition2" just if(condition3)
This is the best that i can do for let you understand
Here the code that i've supposed and tried (give me this error: unexpected T_CONSTANT_ENCAPSED_STRING)

if (condition1 '. if (condition3){ OR condition2}.')
{
Do some php code
}

hope that you understand what i mean :)

Paul M
09-11-2011, 09:41 PM
Assuming I understood you ;

if (condition1 OR (condition2 AND condition3))

Scanu
09-12-2011, 09:11 AM
sorry i will eplain better with some php code supposed

//Settings
$test = true
//true The text will be show if condition 1 or if condition2
//false The text will be show if condition 1


if (condition1 if ($test == "true"){ OR condition2})
{
php
}

Mooff
09-12-2011, 10:05 AM
That is what Pauls code will do?

Scanu
09-12-2011, 10:19 AM
I don't think

Mooff
09-12-2011, 10:25 AM
if (condition1 OR (condition2 AND condition3))
{
....
}


condition3 = true
=>
if (condition1 OR condition2)

condition3 = false
=>
if (condition1)


exactly as you wanted here:

//true The text will be show if condition 1 or if condition2
//false The text will be show if condition 1

Scanu
09-12-2011, 10:32 AM
OH! Sorry!
If this code mean

condition3 = true
=>
if (condition1 OR condition2)

condition3 = false
=>
if (condition1)

Is perfect thanks paul and thanks Mooff i will try it :)

--------------- Added 1315829552 at 1315829552 ---------------

so this code would be right?

if ($vbulletin->userinfo['field'.$field1.''] OR ($vbulletin->userinfo['field'.$field2.''] AND $field2) OR ($vbulletin->userinfo['field'.$field3.''] AND $field3) OR ($vbulletin->userinfo['field'.$field4.''] AND $field4))
{
}
$field1 = $vbulletin->options['var_field1'];
$field2 = $vbulletin->options['var_field2'];
$field3 = $vbulletin->options['var_field3'];
$field4 = $vbulletin->options['var_field4'];

Is very hard to understand if you aren't in my mind

--------------- Added 1315851019 at 1315851019 ---------------

I've tried this code

if ($vbulletin->userinfo['field'.$field1.''] OR ($vbulletin->userinfo['field'.$field2.''] AND $field2) OR ($vbulletin->userinfo['field'.$field3.''] AND $field3) OR ($vbulletin->userinfo['field'.$field4.''] AND $field4))
{}
else{

$template_hook['header_userinfo'] .= 'test';}

$field1 = $vbulletin->options['var_field1'];
$field2 = $vbulletin->options['var_field2'];
$field3 = $vbulletin->options['var_field3'];
$field4 = $vbulletin->options['var_field4'];

but it seems don't work bu the options i have put
1 as var_field1
2 as var_field2
3 as var_field3
4 as var_field4
All fields that i've fill but still seeing "test"