vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Can someone please explain? (https://vborg.vbsupport.ru/showthread.php?t=41114)

Boofo 07-15-2002 11:48 PM

Can someone please explain?
 
Can someone please tell me if I am right in figuring out this line of code below? I am just using an example, but I want to see if what I think I learned is what actually is. :)

(I know this sounds pretty basic to most of you, but I want to learn this stuff and I have to start somewhere, I guess) :)

Here is the code:

PHP Code:

if ($post[userid]!=$bbuserinfo[userid] and $bbuserinfo[canreportposts]==1

Now, if I read this right, it means that if the post does NOT belong to the user, and they ARE able to report posts, then display whatever template you want to display. Does the "!=" mean not where "==" means does? Or can you use a single "=" to do the same thing? If I want to make it so it would display the template if it WAS the user's post, would I do this?

PHP Code:

if ($post[userid]==$bbuserinfo[userid] and $bbuserinfo[canreportposts]==1

If there is another way of doing this, too, please tell me. :) I'll take all of the help in understanding this I can get.

Indy 07-15-2002 11:56 PM

I believe that you are correct with your explanation of the logic of the line of code.

!= Does not equal
if(1 != 2) would return true

== Equals
if(1 == 2) would return false

You use = when assigning a variable.

Boofo 07-16-2002 12:07 AM

Thank you very much. :) Now all I need to figure out is what you mean by the "=" being used to assign a variable. Can you please give me an example? :)

Quote:

Originally posted by Indyshooter
I believe that you are correct with your explanation of the logic of the line of code.

!= Does not equal
if(1 != 2) would return true

== Equals
if(1 == 2) would return false

You use = when assigning a variable.


Admin 07-16-2002 06:27 AM

Code:

$foo = 'bar';
You don't want to use = in conditionals, at least not for now. If you do this:
Code:

if ($foo = 'bar') {
It will be true, since $foo is assigned 'bar', and since the assigment was successful the whole expression returns true (yes, assigments return true/false).

Boofo 07-16-2002 07:35 AM

Ok, now I see what you mean. It's almost like Turbo Pascal when you assign the variables then. And if I wanted to assign a global variable to be able to use anywhere on the site, is global.php where I would put it or could it be done in functions.php?

(I love this stuff! :))

Quote:

Originally posted by FireFly
Code:

$foo = 'bar';
You don't want to use = in conditionals, at least not for now. If you do this:
Code:

if ($foo = 'bar') {
It will be true, since $foo is assigned 'bar', and since the assigment was successful the whole expression returns true (yes, assigments return true/false).

Also, just to make sure I got it. these next 2 lines of code will actually return the same results, right?
PHP Code:

if ($post[userid]!=$bbuserinfo[userid] and $bbuserinfo[canreportposts]==1) { 

PHP Code:

if ($post[userid]!=$bbuserinfo[userid] and $bbuserinfo[canreportposts]!=0) { 



All times are GMT. The time now is 12:57 PM.

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.01050 seconds
  • Memory Usage 1,734KB
  • 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
  • (4)bbcode_code_printable
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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