Jump to content

Search the Community

Showing results for tags 'true'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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 (Dreamweaver, Zend, 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 2 results

  1. 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>
  2. 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
  • 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.