vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   PHP - A condition into a condition (https://vborg.vbsupport.ru/showthread.php?t=270098)

Scanu 09-11-2011 08:38 PM

PHP - A condition into a condition
 
Hi everywone is me again, I have this condition
PHP Code:

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)
PHP Code:

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 ;

PHP Code:

if (condition1 OR (condition2 AND condition3)) 


Scanu 09-12-2011 09:11 AM

sorry i will eplain better with some php code supposed
PHP Code:

//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

Code:

if (condition1 OR (condition2 AND condition3)) 
{
....
}

condition3 = true
=>
if (condition1 OR condition2)

condition3 = false
=>
if (condition1)


exactly as you wanted here:
Quote:

//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
Quote:

condition3 = true
=>
if (condition1 OR condition2)

condition3 = false
=>
if (condition1)
Is perfect thanks paul and thanks Mooff i will try it :)

--------------- Added [DATE]1315829552[/DATE] at [TIME]1315829552[/TIME] ---------------

so this code would be right?
PHP 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))
{
}
$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 [DATE]1315851019[/DATE] at [TIME]1315851019[/TIME] ---------------

I've tried this code
PHP 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"


All times are GMT. The time now is 01:19 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01114 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete