Jump to content

Search the Community

Showing results for tags 'false'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. Php Gurus, Why is it that the RETURN FALSE only echos the last non-matched item ? I had like this: $banned_words = array("0","1","2","3","4","5","6","7","8","9"); $content = "f"; //Tailored for no match to be found. As you can see, the script is tailored not to find any matches. The RETURN FALSE does not show you result like this: Script 2a - No Match: 0 Script 2a - No Match: 1 Script 2a - No Match: 2 Script 2a - No Match: 3 Script 2a - No Match: 4 Script 2a - No Match: 5 Script 2a - No Match: 6 Script 2a - No Match: 7 Script 2a - No Match: 8 Script 2a - No Match: 8 But only shows you like this: Script 2a - No Match: 9 <?php //script 2a: https://stackoverflow.com/questions/32522192/check-if-an-array-element-is-in-a-string $banned_words = array("0","1","2","3","4","5","6","7","8","9"); $content = "f"; //Tailored for no match to be found. foreach ($banned_words as $ban) { if (stripos($content, $ban) !== FALSE) { echo "Script 2a - Match: $ban";?><br><?php return true; //What is the mystery behind the "return true" ? } } echo "Script 2a - No Match: $ban";?><br><?php return false; //What is the mystery behind the "return false" ? //Showing result: No match: 9. //Why is it not showing the other non-matches ? Why showing only the last non-match ? ?> <br>
  2. Folks, Is it true that once the RETURN shows you a result, be it TRUE or FALSE, the script gets executed no further in the script flow ? Did I understand it correctly here: http://php.net/manual/en/functions.returning-values.php I had 2 scripts (2b & 2a) in the same file like so ... My questions are in the comments. If anyone knows the answers then kindly respond. Thanks <?php /* ERROR HANDLING */ declare(strict_types=1); ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); //script 2b: $banned_words = array("0","1","2","3","4","5","6","7","8","9"); $content = "4"; foreach ($banned_words as $ban) { if (stripos($content, $ban) !== FALSE) { echo "Script 2b - Match: $ban";?><br><?php return true; //QUESTION 1: What is the mystery behind the "return true/false" ? Why the script does not flow below this point to the rest of the script plus to the other script script 2a ? } } echo "Script 2b - No Match: $ban";?><br><?php return false; //What is the mystery behind the "return false" ? //Showing result: Script 2b - Match: 4. //QUESTION 2: Why is it not showing the other matches & non-matches ? Why showing only the first match ? ?> <br> <?php //script 2a: $banned_words = array("0","1","2","3","4","5","6","7","8","9"); $content = "f"; //Tailored for no match to be found. foreach ($banned_words as $ban) { if (stripos($content, $ban) !== FALSE) { echo "Script 2a - Match: $ban";?><br><?php return true; } } echo "Script 2a - No Match: $ban";?><br><?php return false; ?> <br>
  3. Hi there, I have a simple question to ask: Say i have a PHP script: <?php var_dump($undeclaredVariable); /* The output is NULL */ if($a==$b) { if($c == $d) { $undeclaredVariable = TRUE; } else { $undeclaredVariable = FALSE; } } if($undeclaredVariable == TRUE) { echo 'the undeclared variable is TRUE'; } if($undeclaredVariable == FALSE) { echo 'the undeclared variable is FALSE'; } ?> Reading the PHP Type Comparison Table: $x = null; boolean if($x) = FALSE Using the code above, I see the "the undeclared variable is FALSE", which is OK since it proves the PHP documentation. But as you can see, if $a !=$b then the $undeclaredVarable will not be declared(defined). Is this an "OK" way to work this out? Or should I find a way to declare the variable whatever the case? Thanks in advance, Christos
  4. In the elseif below if the $group_num is in the $dont_print I don't want add the info, what am I doing wrong $dont_print = array(0, 12); foreach ($group_array as $key => $group_num) { if (!$add_on_sql) {$add_on_sql = 'WHERE id_group = '.$group_num.'';} elseif (in_array($group_num, $dont_print, FALSE)) {$add_on_sql .= ' OR id_group = '.$group_num.'';} } Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.