Unsupported browser

This site was designed for modern browsers and tested with Internet Explorer version 10 and later.

It may not look or work correctly on your browser.

  • PHP Scripts

PHP Control Structures and Loops: if, else, for, foreach, while, and More

Sajal Soni

  • Bahasa Indonesia

Today, we're going to discuss control structures and loops in PHP. I'll show you how to use all the main control structures that are supported in PHP, like if, else, for, foreach, while, and more.

What Is a Control Structure?

In simple terms, a control structure allows you to control the flow of code execution in your application. Generally, a program is executed sequentially, line by line, and a control structure allows you to alter that flow, usually depending on certain conditions.

Control structures are core features of the PHP language that allow your script to respond differently to different inputs or situations. This could allow your script to give different responses based on user input, file contents, or some other data.

The following flowchart explains how a control structure works in PHP.

PHP Control Structures and Loops if Condition Flow

As you can see in the above diagram, first a condition is checked. If the condition is true, the conditional code will be executed. The important thing to note here is that code execution continues normally after conditional code execution.

Let's consider the following example.

PHP Control Structures and Loops elseif Condition Flow

In the above example, the program checks whether or not the user is logged in. Based on the user's login status, they will be redirected to either the  Login  page or the  My Account  page. In this case, a control structure ends code execution by redirecting users to a different page. This is a crucial ability of the PHP language.

PHP supports a number of different control structures:

Let's take a look at a few of these control structures with examples.

Learning PHP Control Structures

In the previous section, we learned the basics of control structures in PHP and their usefulness in application development. In this section, we'll go through a couple of important control structures that you'll end up using frequently in your day-to-day application development.

PHP If Statement

The  if  construct allows you to execute a piece of code if the expression provided along with it evaluates to true.

Let's have a look at the following example to understand how it actually works.

= 50;
($age > 30)
"Your age is greater than 30!";

The above example should output the  Your age is greater than 30!  message since the expression evaluates to true. In fact, if you want to execute only a single statement, the above example can be rewritten without brackets, as shown in the following snippet.

= 50;
($age > 30)
"Your age is greater than 30!";

On the other hand, if you have more than one statement to execute, you must use brackets, as shown in the following snippet.

(is_array($user))
= isset($user['user_id']) ? $user['user_id'] : '';
= isset($user['username']) ? $user['username'] : '';

PHP Else Statement

In the previous section, we discussed the  if  construct, which allows you to execute a piece of code if the expression evaluates to true. On the other hand, if the expression evaluates to false, it won't do anything. More often than not, you also want to execute a different code snippet if the expression evaluates to false. That's where the  else  statement comes into the picture.

You always use the  else  statement in conjunction with an  if  statement. Basically, you can define it as shown in the following pseudo-code.

(expression)

Let's revise the previous example to understand how it works.

= 50;
($age < 30)
"Your age is less than 30!";
"Your age is greater than or equal to 30!";

So when you have two choices, and one of them must be executed, you can use the  if-else  construct.

PHP Else If Statement

We can consider the  elseif  statement as an extension to the  if-else  construct. If you've got more than two choices to choose from, you can use the  elseif  statement.

Let's study the basic structure of the  elseif  statement, as shown in the following pseudo-code.

(expression1)
(expression2)
(expression3)

Again, let's try to understand it using a real-world example.

= 50;
($age < 30)
"Your age is less than 30!";
($age > 30 && $age < 40)
"Your age is between 30 and 40!";
($age > 40 && $age < 50)
"Your age is between 40 and 50!";
"Your age is greater than 50!";

As you can see in the above example, we have multiple conditions, so we've used a series of  elseif  statements. In the event that all  if  conditions evaluate to false, it executes the code provided in the last  else  statement.

PHP Switch Statement

The switch statement is somewhat similar to the  elseif  statement which we've just discussed in the previous section. The only difference is the expression which is being checked.

In the case of the  elseif  statement, you have a set of different conditions, and an appropriate action will be executed based on a condition. On the other hand, if you want to compare a variable with different values, you can use the  switch  statement.

As usual, an example is the best way to understand the  switch  statement.

= 'Code';
($favourite_site) {
'Business':
"My favourite site is business.tutsplus.com!";
;
'Code':
"My favourite site is code.tutsplus.com!";
;
'Web Design':
"My favourite site is webdesign.tutsplus.com!";
;
'Music':
"My favourite site is music.tutsplus.com!";
;
'Photography':
"My favourite site is photography.tutsplus.com!";
;
:
"I like everything at tutsplus.com!";

As you can see in the above example, we want to check the value of the  $favourite_site  variable, and based on the value of the  $favourite_site  variable, we want to print a message.

For each value you want to check with the  $favourite_site  variable, you have to define the  case  block. If the value is matched with a case, the code associated with that case block will be executed. After that, you need to use the  break  statement to end code execution. If you don't use the  break  statement, script execution will be continued up to the last block in the switch statement.

Finally, if you want to execute a piece of code if the variable's value doesn't match any case, you can define it under the  default  block. Of course, it's not mandatory—it's just a way to provide a  default  case.

So that's the story of conditional control structures. We'll discuss loops in PHP in the next section.

Loops in PHP

Loops in PHP are useful when you want to execute a piece of code repeatedly until a condition evaluates to false. So code is executed repeatedly as long as a condition evaluates to true, and as soon as the condition evaluates to false, the script continues executing the code after the loop.

The following flowchart explains how loops work in PHP.

Loop Flow

As you can see in the above screenshot, a loop contains a condition. If the condition evaluates to true, the conditional code is executed. After execution of the conditional code, control goes back to the loop condition, and the flow continues until the condition evaluates to false.

In this section, we'll go through the different types of loops supported in PHP.

While Loop in PHP

The  while  loop is used when you want to execute a piece of code repeatedly until the  while  condition evaluates to false.

You can define it as shown in the following pseudo-code.

(expression)

Let's have a look at a real-world example to understand how the  while  loop works in PHP.

= 0;
$i = 0;
",";
$j = 1;
",";
=0;
($max < 10 )
= $i + $j;
= $j;
= $result;
= $max + 1;
$result;
",";

If you're familiar with the Fibonacci series, you might recognize what the above program does—it outputs the Fibonacci series for the first ten numbers. The  while  loop is generally used when you don't know the number of iterations that are going to take place in a loop.

Do-While Loop in PHP

The  do-while  loop is very similar to the  while  loop, with the only difference being that the while condition is checked at the end of the first iteration. Thus, we can guarantee that the loop code is executed at least once, irrespective of the result of the while expression.

Let's have a look at the syntax of the  do-while  loop.

while (expression);

Let's go through a real-world to understand possible cases where you can use the  do-while  loop.

= fopen("file.txt", "r");
($handle)
= fgets($handle);
while($line !== false);
($handle);

In the above example, we're trying to read a file line by line. Firstly, we've opened a file for reading. In our case, we're not sure if the file contains any content at all. Thus, we need to execute the  fgets  function at least once to check if a file contains any content. So we can use the  do-while  loop here.  do-while  evaluates the condition  after  the first iteration of the loop.

For Loop in PHP

Generally, the  for  loop is used to execute a piece of code a specific number of times. In other words, if you already know the number of times you want to execute a block of code, it's the  for  loop which is the best choice.

Let's have a look at the syntax of the  for  loop.

(expr1; expr2; expr3)

The  expr1  expression is used to initialize variables, and it's always executed. The  expr2  expression is also executed at the beginning of a loop, and if it evaluates to true, the loop code is executed. After execution of the loop code, the  expr3  is executed. Generally, the  expr3  is used to alter the value of a variable which is used in the  expr2  expression.

Let's go through the following example to see how it works.

($i=1; $i<=10; ++$i)
sprintf("The square of %d is %d.</br>", $i, $i*$i);

The above program outputs the square of the first ten numbers. It initializes  $i  to 1, repeats as long as  $i  is less than or equal to 10, and adds 1 to  $i  at each iteration.

For Each in PHP

The  foreach  loop is used to iterate over array variables. If you have an array variable, and you want to go through each element of that array, the  foreach  loop is the best choice.

Let's have a look at a couple of examples.

= array('apple', 'banana', 'orange', 'grapes');
($fruits as $fruit)
$fruit;
"<br/>";
= array('name' => 'John Smith', 'age' => 30, 'profession' => 'Software Engineer');
($employee as $key => $value)
sprintf("%s: %s</br>", $key, $value);
"<br/>";

If you want to access array values, you can use the first version of the  foreach  loop, as shown in the above example. On the other hand, if you want to access both a key and a value, you can do it as shown in the  $employee  example above.

Breaking Out of the Loop

There are times when you might want to break out of a loop before it runs its course. This can be achieved easily using the  break  keyword. It will get you out of the current  for ,  foreach ,  while ,  do-while , or  switch  structure.

You can also use  break  to get out of multiple nested loops by supplying a numeric argument. For example, using  break 3  will break you out of 3 nested loops. However, you cannot pass a variable as the numeric argument if you are using a PHP version greater than or equal to 5.4.

'Simple Break';
($i = 1; $i <= 2; $i++) {
"\n".'$i = '.$i.' ';
($j = 1; $j <= 5; $j++) {
($j == 2) {
;
'$j = '.$j.' ';
'Multi-level Break';
($i = 1; $i <= 2; $i++) {
"\n".'$i = '.$i.' ';
($j = 1; $j <= 5; $j++) {
($j == 2) {
2;
'$j = '.$j.' ';

Another keyword that can interrupt loops in PHP is  continue . However, this only skips the rest of the current loop iteration instead of breaking out of the loop altogether. Just like  break , you can also use a numerical value with  continue  to specify how many nested loops it should skip for the current iteration.

'Simple Continue';
($i = 1; $i <= 2; $i++) {
"\n".'$i = '.$i.' ';
($j = 1; $j <= 5; $j++) {
($j == 2) {
;
'$j = '.$j.' ';
'Multi-level Continue';
($i = 1; $i <= 2; $i++) {
"\n".'$i = '.$i.' ';
($j = 1; $j <= 5; $j++) {
($j == 2) {
2;
'$j = '.$j.' ';

In this article, we discussed different control structures and loops in PHP. They are an essential part of PHP—or any programming language for that matter.

Learn PHP With a Free Online Course

If you want to learn PHP, check out our  free online course on PHP fundamentals !

php while assignment in condition

In this course, you'll learn the fundamentals of PHP programming. You'll start with the basics, learning how PHP works and writing simple PHP loops and functions. Then you'll build up to coding classes for simple object-oriented programming (OOP). Along the way, you'll learn all the most important skills for writing apps for the web: you'll get a chance to practice responding to GET and POST requests, parsing JSON, authenticating users, and using a MySQL database.

php while assignment in condition

Popular Articles

  • Php Remove Last Character From String (Nov 08, 2023)
  • Php Reset (Nov 08, 2023)
  • Php Optional Parameters (Nov 08, 2023)
  • Php Null (Nov 08, 2023)
  • Php Join Array (Nov 08, 2023)

PHP While Loop

PHP While Loop

Switch to English

Table of Contents

Introduction

Understanding php while loop, working with php while loop, tips and tricks, common error-prone cases and how to avoid them.

  • The basic syntax of a while loop in PHP is as follows:
  • Example of a basic PHP while loop:
  • Always remember to include a statement within your loop that changes the value of your conditional variable. If you forget to increment or somehow alter the conditional variable, your loop will run indefinitely, causing a runtime error or causing your program to crash.
  • Be careful with the conditions in your loop. If the condition is never false, the loop will continue indefinitely, which can lead to unexpected results or errors.
  • Infinite Loops: One of the most common mistakes beginners make is creating an infinite loop. This happens when the loop condition is always true. To avoid this, make sure your loop has a reachable end point. For instance, in the example above, our loop will end when $i is greater than 5.
  • Off-by-One Errors: These are common in loops where the boundaries are not defined correctly. Always double-check your loop's start and end points. In the example below, the loop should stop when $i is less than or equal to 10, not less than 10.

In this tutorial you will learn how to repeat a series of actions using loops in PHP.

Different Types of Loops in PHP

Loops are used to execute the same block of code again and again, as long as a certain condition is met. The basic idea behind a loop is to automate the repetitive tasks within a program to save the time and effort. PHP supports four different types of loops.

  • while — loops through a block of code as long as the condition specified evaluates to true.
  • do…while — the block of code executed once and then condition is evaluated. If the condition is true the statement is repeated as long as the specified condition is true.
  • for — loops through a block of code until the counter reaches a specified number.
  • foreach — loops through a block of code for each element in an array.

You will also learn how to loop through the values of array using foreach() loop at the end of this chapter. The foreach() loop work specifically with arrays.

PHP while Loop

The while statement will loops through a block of code as long as the condition specified in the while statement evaluate to true.

The example below define a loop that starts with $i=1 . The loop will continue to run as long as $i is less than or equal to 3. The $i will increase by 1 each time the loop runs:

PHP do…while Loop

The do-while loop is a variant of while loop, which evaluates the condition at the end of each loop iteration. With a do-while loop the block of code executed once, and then the condition is evaluated, if the condition is true, the statement is repeated as long as the specified condition evaluated to is true.

The following example define a loop that starts with $i=1 . It will then increase $i with 1, and print the output. Then the condition is evaluated, and the loop will continue to run as long as $i is less than, or equal to 3.

Difference Between while and do…while Loop

The while loop differs from the do-while loop in one important way — with a while loop, the condition to be evaluated is tested at the beginning of each loop iteration, so if the conditional expression evaluates to false, the loop will never be executed.

With a do-while loop, on the other hand, the loop will always be executed once, even if the conditional expression is false, because the condition is evaluated at the end of the loop iteration rather than the beginning.

PHP for Loop

The for loop repeats a block of code as long as a certain condition is met. It is typically used to execute a block of code for certain number of times.

The parameters of for loop have following meanings:

  • initialization — it is used to initialize the counter variables, and evaluated once unconditionally before the first execution of the body of the loop.
  • condition — in the beginning of each iteration, condition is evaluated. If it evaluates to true , the loop continues and the nested statements are executed. If it evaluates to false , the execution of the loop ends.
  • increment — it updates the loop counter with a new value. It is evaluate at the end of each iteration.

The example below defines a loop that starts with $i=1 . The loop will continued until $i is less than, or equal to 3. The variable $i will increase by 1 each time the loop runs:

PHP foreach Loop

The foreach loop is used to iterate over arrays.

The following example demonstrates a loop that will print the values of the given array:

There is one more syntax of foreach loop, which is extension of the first.

Bootstrap UI Design Templates

Is this website helpful to you? Please give us a like , or share your feedback to help us improve . Connect with us on Facebook and Twitter for the latest updates.

Interactive Tools

BMC

  • Language Reference
  • Control Structures

(PHP 4, PHP 5, PHP 7, PHP 8)

The if construct is one of the most important features of many languages, PHP included. It allows for conditional execution of code fragments. PHP features an if structure that is similar to that of C: if (expr) statement

As described in the section about expressions , expression is evaluated to its Boolean value. If expression evaluates to true , PHP will execute statement , and if it evaluates to false - it'll ignore it. More information about what values evaluate to false can be found in the 'Converting to boolean' section.

The following example would display a is bigger than b if $a is bigger than $b : <?php if ( $a > $b ) echo "a is bigger than b" ; ?>

Often you'd want to have more than one statement to be executed conditionally. Of course, there's no need to wrap each statement with an if clause. Instead, you can group several statements into a statement group. For example, this code would display a is bigger than b if $a is bigger than $b , and would then assign the value of $a into $b : <?php if ( $a > $b ) { echo "a is bigger than b" ; $b = $a ; } ?>

If statements can be nested infinitely within other if statements, which provides you with complete flexibility for conditional execution of the various parts of your program.

Improve This Page

User contributed notes 4 notes.

To Top

While Loop In PHP

We will discuss the syntax and usage of PHP while loops , provide examples of how to use it in practice, and offer best practices to help you write efficient and effective code.

Whether you are a beginner or an experienced PHP developer, this article will provide valuable insights into how to use the PHP while loop to its fullest potential.

In PHP , while loops are iterative control structures.

As long as a condition is true , a block of code can be executed repeatedly.

  • While Loop In PHP:
  • PHP while Loop:

PHP while Loop

PHP While loops allow you to execute code repeatedly while the condition is true .

While loops are a basic programming feature commonly found in many programming languages, and they are useful for automating repetitive tasks, iterating through data structures, and many other things.

The condition in the while loop can be any expression that returns a boolean value ( true or false ).

The code block within the curly braces {} is executed repeatedly as long as the condition is true .

One of the advantages of the while loop is its flexibility. Unlike the for loop, which requires a fixed number of iterations, the while loop can be used to process data with unknown or varying lengths.

For example, you could use a while loop to read data from a file, process user input until a specific condition is met, or iterate over a database result set.

Here is an example of using the PHP while loop to print the numbers from 1 to 10:

Example: 

Example explanation.

In above example, the variable $a is initialized with a value of 1. The while loop starts by checking the condition that $a is less than or equal to 10. Since $a is initially equal to 1, the condition is true and the code block within the loop is executed.

The code block simply prints the value of $a to the screen using the echo statement, along with a line break ( <br> ).

The value of $a is then incremented by one using the $a++ statement.

After each iteration of the loop, the condition is checked again to determine whether the loop should continue.

If the value of $a is still less than or equal to 10, the loop will continue and execute the code block again.

This process repeats until the value of $a is greater than 10 , at which point the condition is no longer true and the loop terminates.

Below example prints the alphabets from “A” to “H”:

PHP while Loop example output

Here is an example of counting by tens up to 50:

Example Explained

  • $a = 0; – Set $a to 0 as the start value of the loop counter.
  • $a <= 5 – Repeat this till $a is less than or equal to 50.
  • $a+=10; – Each iteration increases the loop counter by 10.

While loops can also be combined with conditional statements such as if-else statement, to create more complex code blocks.

One of the common mistakes while using PHP while loop is to create an infinite loop, which is a loop that runs continuously without stopping.

This could happen if the condition in the while loop is always true , or if the code block within the loop does not change the condition.

Therefore, it is important to carefully evaluate the conditions and ensure that the loop terminates at some point.

Below is an example of printing all even numbers up to 20:

Explanation:

Above code demonstrates the use of PHP while loop to print even numbers from 0 to 20.

  • The code defines a variable $a and assigns it the value of 0.
  • The code then enters a while loop. The loop will continue to execute as long as the value of $a is less than or equal to 20.
  • Inside the while loop, an if statement is used to check if the value of $a is an even number. The condition $a % 2 == 0 checks if $a is divisible by 2 with no remainder, which means it is an even number.
  • If the value of $a is an even number, the echo statement is executed, which displays a message indicating that the number is even.
  • The value of $a is then incremented by 1 using the $a++ statement, which ensures that the loop will eventually terminate.
  • The loop continues to execute, and each time the value of $a is checked, it is either printed as an even number or skipped over.
  • Once the value of $a is greater than 20, the loop terminates, and program execution continues.

So the code demonstrates how to use PHP while loop to print even numbers.

It also shows how to use the modulus operator % to check if a number is even or odd .

In conclusion, PHP while loop is an essential tool for any PHP programmer. It provides a simple and flexible way to automate repetitive tasks and control program flow. By understanding the syntax and usage of the while loop, you can create more efficient and effective PHP programs.

icon

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

Feeling bored?

Revitalize and stimulate your mind by solving puzzles in game.

php while assignment in condition

Mrexamples 1024 Move Game

Home » PHP Tutorial » PHP Assignment Operators

PHP Assignment Operators

Summary : in this tutorial, you will learn about the most commonly used PHP assignment operators.

Introduction to the PHP assignment operator

PHP uses the = to represent the assignment operator. The following shows the syntax of the assignment operator:

On the left side of the assignment operator ( = ) is a variable to which you want to assign a value. And on the right side of the assignment operator ( = ) is a value or an expression.

When evaluating the assignment operator ( = ), PHP evaluates the expression on the right side first and assigns the result to the variable on the left side. For example:

In this example, we assigned 10 to $x, 20 to $y, and the sum of $x and $y to $total.

The assignment expression returns a value assigned, which is the result of the expression in this case:

It means that you can use multiple assignment operators in a single statement like this:

In this case, PHP evaluates the right-most expression first:

The variable $y is 20 .

The assignment expression $y = 20 returns 20 so PHP assigns 20 to $x . After the assignments, both $x and $y equal 20.

Arithmetic assignment operators

Sometimes, you want to increase a variable by a specific value. For example:

How it works.

  • First, $counter is set to 1 .
  • Then, increase the $counter by 1 and assign the result to the $counter .

After the assignments, the value of $counter is 2 .

PHP provides the arithmetic assignment operator += that can do the same but with a shorter code. For example:

The expression $counter += 1 is equivalent to the expression $counter = $counter + 1 .

Besides the += operator, PHP provides other arithmetic assignment operators. The following table illustrates all the arithmetic assignment operators:

OperatorExampleEquivalentOperation
+=$x += $y$x = $x + $yAddition
-=$x -= $y$x = $x – $ySubtraction
*=$x *= $y$x = $x * $yMultiplication
/=$x /= $y$x = $x / $yDivision
%=$x %= $y$x = $x % $yModulus
**=$z **= $y$x = $x ** $yExponentiation

Concatenation assignment operator

PHP uses the concatenation operator (.) to concatenate two strings. For example:

By using the concatenation assignment operator you can concatenate two strings and assigns the result string to a variable. For example:

  • Use PHP assignment operator ( = ) to assign a value to a variable. The assignment expression returns the value assigned.
  • Use arithmetic assignment operators to carry arithmetic operations and assign at the same time.
  • Use concatenation assignment operator ( .= )to concatenate strings and assign the result to a variable in a single statement.

PHP Tutorial

Php advanced, mysql database, php examples, php reference, php if statements.

Conditional statements are used to perform different actions based on different conditions.

PHP Conditional Statements

Very often when you write code, you want to perform different actions for different conditions. You can use conditional statements in your code to do this.

In PHP we have the following conditional statements:

  • if statement - executes some code if one condition is true
  • if...else statement - executes some code if a condition is true and another code if that condition is false
  • if...elseif...else statement - executes different codes for more than two conditions
  • switch statement - selects one of many blocks of code to be executed

PHP - The if Statement

The if statement executes some code if one condition is true.

Output "Have a good day!" if 5 is larger than 3:

We can also use variables in the if statement:

Output "Have a good day!" if $t is less than 20:

Get Certified

COLOR PICKER

colorpicker

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]

Top Tutorials

Top references, top examples, get certified.

CodedTag

If Condition

The IF statement in PHP helps to see if a condition is true or not. If it is true, it makes the script do something different while it’s running.

The IF statement in PHP can be written like this:

So, it runs the block of code inside the two curly braces if the main condition is met. However, if the condition is not true, it skips those commands.

Here is a figure that shows you the process of the “if” condition.

PHP if condition

In the following sections, you will see other kinds of PHP IF condition. So let’s begin with the no curly braces.

IF Statement Without Curly Braces

When you write an ‘if’ statement in PHP, you can ignore the two curly braces; however, PHP will only execute one line of code, which is the line following the condition, or ignore it if the result is not true. Here is the syntax:

So, writing multiple lines is not permitted—only one is allowed.

Let’s see an example:

Let’s see another way for “if” condition in PHP.

Embedding IF Statements within HTML Markup

Imagine you’re writing a story on your website, but you want the story to change a bit if the reader is a kid. You could use an IF statement in your PHP code to do this magic trick. It’s like saying, “If the reader is a kid, show this friendly dragon picture. Otherwise, you can show another image by using else block”.

Here’s a simple way to do it:

You can also use the if(): and endif; constructs within HTML blocks. For example:

In the following section, you will learn how to write if condition inside another if condition.

Nested IF Statement in PHP

The concept of nesting refers to placing one IF condition or more within another IF condition. here is an example

Anyway, in the following section, you will learn how variables operate depending on whether the condition is true or false.

Using Variables with IF Statements in PHP

Sometimes, you might want to give a new value to a variable when certain conditions are met. If the condition is true, the variable gets this new value. Let’s look at an example to make it clearer.

But what happens if the condition turns out to be false? To answer this question, you need to look at the following example. As it produces an error because the variable is not defined if the PHP interpreter skips the line inside the condition.

This will show you the following error message.

Anyway let’s see more examples to gain a deeper understanding.

Here, we’ll check if a number is positive. If the condition is true, a message will be displayed.

You can also nest if statements within each other to check multiple conditions in a more detailed manner.

Let’s summarize it in a few points.

Wrapping Up

The IF statement in PHP checks whether a condition is true, allowing the script to perform different actions based on this check. Here’s a concise summary of the key points discussed:

  • The IF statement evaluates a condition. If the condition is true, it executes the code block within the curly braces {} . If the condition is false, the code block is skipped.
  • For a single-line condition, PHP allows an IF statement without curly braces, executing only the immediate line following the condition if it’s true.
  • IF statements can dynamically change HTML content, such as displaying different images based on conditions. This is useful for personalizing web pages based on user data or preferences.
  • You can place IF statements within other IF statements to create complex decision trees.

Thank you for reading. Happy Coding!

Did you find this article helpful?

 width=

Sorry about that. How can we improve it ?

  • Facebook -->
  • Twitter -->
  • Linked In -->
  • Install PHP
  • Hello World
  • PHP Constant
  • PHP Comments

PHP Functions

  • Parameters and Arguments
  • Anonymous Functions
  • Variable Function
  • Arrow Functions
  • Variadic Functions
  • Named Arguments
  • Callable Vs Callback
  • Variable Scope

Control Structures

  • If-else Block
  • Break Statement

PHP Operators

  • Operator Precedence
  • PHP Arithmetic Operators
  • Assignment Operators
  • PHP Bitwise Operators
  • PHP Comparison Operators
  • PHP Increment and Decrement Operator
  • PHP Logical Operators
  • PHP String Operators
  • Array Operators
  • Conditional Operators
  • Ternary Operator
  • PHP Enumerable
  • PHP NOT Operator
  • PHP OR Operator
  • PHP Spaceship Operator
  • AND Operator
  • Exclusive OR
  • Spread Operator
  • Null Coalescing Operator

Data Format and Types

  • PHP Data Types
  • PHP Type Juggling
  • PHP Type Casting
  • PHP strict_types
  • Type Hinting
  • PHP Boolean Type
  • PHP Iterable
  • PHP Resource
  • Associative Arrays
  • Multidimensional Array

String and Patterns

  • Remove the Last Char

PHP Tutorial

  • PHP Tutorial
  • PHP - Introduction
  • PHP - Installation
  • PHP - History
  • PHP - Features
  • PHP - Syntax
  • PHP - Hello World
  • PHP - Comments
  • PHP - Variables
  • PHP - Echo/Print
  • PHP - var_dump
  • PHP - $ and $$ Variables
  • PHP - Constants
  • PHP - Magic Constants
  • PHP - Data Types
  • PHP - Type Casting
  • PHP - Type Juggling
  • PHP - Strings
  • PHP - Boolean
  • PHP - Integers
  • PHP - Files & I/O
  • PHP - Maths Functions
  • PHP - Heredoc & Nowdoc
  • PHP - Compound Types
  • PHP - File Include
  • PHP - Date & Time
  • PHP - Scalar Type Declarations
  • PHP - Return Type Declarations
  • PHP Operators
  • PHP - Operators
  • PHP - Arithmatic Operators
  • PHP - Comparison Operators
  • PHP - Logical Operators
  • PHP - Assignment Operators
  • PHP - String Operators
  • PHP - Array Operators
  • PHP - Conditional Operators
  • PHP - Spread Operator
  • PHP - Null Coalescing Operator
  • PHP - Spaceship Operator
  • PHP Control Statements
  • PHP - Decision Making
  • PHP - If…Else Statement
  • PHP - Switch Statement
  • PHP - Loop Types
  • PHP - For Loop
  • PHP - Foreach Loop

PHP - While Loop

  • PHP - Do…While Loop
  • PHP - Break Statement
  • PHP - Continue Statement
  • PHP - Arrays
  • PHP - Indexed Array
  • PHP - Associative Array
  • PHP - Multidimensional Array
  • PHP - Array Functions
  • PHP - Constant Arrays
  • PHP Functions
  • PHP - Functions
  • PHP - Function Parameters
  • PHP - Call by value
  • PHP - Call by Reference
  • PHP - Default Arguments
  • PHP - Named Arguments
  • PHP - Variable Arguments
  • PHP - Returning Values
  • PHP - Passing Functions
  • PHP - Recursive Functions
  • PHP - Type Hints
  • PHP - Variable Scope
  • PHP - Strict Typing
  • PHP - Anonymous Functions
  • PHP - Arrow Functions
  • PHP - Variable Functions
  • PHP - Local Variables
  • PHP - Global Variables
  • PHP Superglobals
  • PHP - Superglobals
  • PHP - $GLOBALS
  • PHP - $_SERVER
  • PHP - $_REQUEST
  • PHP - $_POST
  • PHP - $_GET
  • PHP - $_FILES
  • PHP - $_ENV
  • PHP - $_COOKIE
  • PHP - $_SESSION
  • PHP File Handling
  • PHP - File Handling
  • PHP - Open File
  • PHP - Read File
  • PHP - Write File
  • PHP - File Existence
  • PHP - Download File
  • PHP - Copy File
  • PHP - Append File
  • PHP - Delete File
  • PHP - Handle CSV File
  • PHP - File Permissions
  • PHP - Create Directory
  • PHP - Listing Files
  • Object Oriented PHP
  • PHP - Object Oriented Programming
  • PHP - Classes and Objects
  • PHP - Constructor and Destructor
  • PHP - Access Modifiers
  • PHP - Inheritance
  • PHP - Class Constants
  • PHP - Abstract Classes
  • PHP - Interfaces
  • PHP - Traits
  • PHP - Static Methods
  • PHP - Static Properties
  • PHP - Namespaces
  • PHP - Object Iteration
  • PHP - Encapsulation
  • PHP - Final Keyword
  • PHP - Overloading
  • PHP - Cloning Objects
  • PHP - Anonymous Classes
  • PHP Web Development
  • PHP - Web Concepts
  • PHP - Form Handling
  • PHP - Form Validation
  • PHP - Form Email/URL
  • PHP - Complete Form
  • PHP - File Inclusion
  • PHP - GET & POST
  • PHP - File Uploading
  • PHP - Cookies
  • PHP - Sessions
  • PHP - Session Options
  • PHP - Sending Emails
  • PHP - Sanitize Input
  • PHP - Post-Redirect-Get (PRG)
  • PHP - Flash Messages
  • PHP - AJAX Introduction
  • PHP - AJAX Search
  • PHP - AJAX XML Parser
  • PHP - AJAX Auto Complete Search
  • PHP - AJAX RSS Feed Example
  • PHP - XML Introduction
  • PHP - Simple XML Parser
  • PHP - SAX Parser Example
  • PHP - DOM Parser Example
  • PHP Login Example
  • PHP - Login Example
  • PHP - Facebook and Paypal Integration
  • PHP - Facebook Login
  • PHP - Paypal Integration
  • PHP - MySQL Login
  • PHP Advanced
  • PHP - MySQL
  • PHP.INI File Configuration
  • PHP - Array Destructuring
  • PHP - Coding Standard
  • PHP - Regular Expression
  • PHP - Error Handling
  • PHP - Try…Catch
  • PHP - Bugs Debugging
  • PHP - For C Developers
  • PHP - For PERL Developers
  • PHP - Frameworks
  • PHP - Core PHP vs Frame Works
  • PHP - Design Patterns
  • PHP - Filters
  • PHP - Callbacks
  • PHP - Exceptions
  • PHP - Special Types
  • PHP - Hashing
  • PHP - Encryption
  • PHP - is_null() Function
  • PHP - System Calls
  • PHP - HTTP Authentication
  • PHP - Swapping Variables
  • PHP - Closure::call()
  • PHP - Filtered unserialize()
  • PHP - IntlChar
  • PHP - CSPRNG
  • PHP - Expectations
  • PHP - Use Statement
  • PHP - Integer Division
  • PHP - Deprecated Features
  • PHP - Removed Extensions & SAPIs
  • PHP - FastCGI Process
  • PHP - PDO Extension
  • PHP - Built-In Functions
  • PHP Useful Resources
  • PHP - Questions & Answers
  • PHP - Quick Guide
  • PHP - Useful Resources
  • PHP - Discussion
  • Selected Reading
  • UPSC IAS Exams Notes
  • Developer's Best Practices
  • Questions and Answers
  • Effective Resume Writing
  • HR Interview Questions
  • Computer Glossary

The easiest way to create a loop in a PHP script is with the while construct. The syntax of while loop in PHP is similar to that in C language. The loop body block will be repeatedly executed as long as the Boolean expression in the while statement is true.

The following flowchart helps in understanding how the while loop in PHP works −

PHP While Loop

The value of the expression is checked each time at the beginning of the loop. If the while expression evaluates to false from the very beginning, the loop won't even be run once. Even if the expression becomes false during the execution of the block, the execution will not stop until the end of the iteration.

The syntax of while loop can be expressed as follows −

The following code shows a simple example of how the while loop works in PHP. The variable $x is initialized to 1 before the loop begins. The loop body is asked to execute as long as it is less than or equal to 10. The echo statement in the loop body prints the current iteration number, and increments the value of x , so that the condition will turn false eventually.

It will produce the following output −

Note that the test condition is checked at the beginning of each iteration. Even if the condition turns false inside the loop, the execution will not stop until the end of the iteration.

In the following example, "x" is incremented by 3 in each iteration. On the third iteration, "x" becomes 9. Since the test condition is still true, the next round takes place in which "x" becomes 12. As the condition turns false, the loop stops.

It is not always necessary to have the looping variable incrementing. If the initial value of the loop variable is greater than the value at which the loop is supposed to end, then it must be decremented.

Iterating an Array with "while"

An indexed array in PHP is a collection of elements, each of which is identified by an incrementing index starting from 0.

You can traverse an array by constituting a while loop by repeatedly accessing the element at the xth index till "x" reaches the length of the array. Here, "x" is a counter variable, incremented with each iteration. We also need a count() function that returns the size of the array.

Take a look at the following example −

Nested "while" Loops

You may include a while loop inside another while loop. Both the outer and inner while loops are controlled by two separate variables, incremented after each iteration.

Note that "j" which is the counter variable for the inner while loop is re-initialized to 1 after it takes all the values so that for the next value of "i", "j" again starts from 1.

Traversing the Characters in a String

In PHP, a string can be considered as an indexed collection of characters. Hence, a while loop with a counter variable going from "0" to the length of string can be used to fetch one character at a time.

The following example counts number of vowels in a given string. We use strlen() to obtain the length and str_contains() to check if the character is one of the vowels.

Using the "endwhile" Statement

PHP also lets you use an alternative syntax for the while loop. Instead of clubbing more than one statement in curly brackets, the loop body is marked with a ":" (colon) symbol after the condition and the endwhile statement at the end.

Note that the endwhile statement ends with a semicolon.

  • Discussion Forums
  • Configuration and Installation

Unable to get Approver for po as condition based in Assignment and approval screen.

  • 4 days ago 29 June 2024

Badge

  • vishalsharma49

 Hello Experts, I am facing issue while approving po based on condition applied in Assignment and approval screen ,please have a look to the screenshot attached with it , do i have missed something in mapping.

  • When Order total is >100

php while assignment in condition

2.When order total is >1000

php while assignment in condition

3.When order total is >10,000

php while assignment in condition

So i all the three conditions Assigned to and approver are the same. 

  • Assignment Maps and Approvals
  • Purchase Orders

Already have an account? Login

Social Login

Login to the community.

Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

Scanning file for viruses.

Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.

This file cannot be downloaded

Sorry, our virus scanner detected that this file isn't safe to download.

  • Privacy Policy
  • Terms of Use
  • Report an Outage
  • Share full article

Advertisement

Supported by

Celine Dion Had a Medical Emergency. The Camera Kept Rolling

Irene Taylor, director of the new documentary “I Am: Celine Dion,” talks about the decision to include a grueling scene of the pop star in crisis.

In a scene from the movie, Celine Dion is seen in profile, clenching a fist and making a face.

By Annie Aguiar

This article contains spoilers.

Celine Dion welcomed the cameras. For the new documentary “ I Am: Celine Dion ” (streaming on Amazon Prime Video ), the singer set no restrictions on what to film.

What follows is a painfully intimate portrait of a pop star’s body fighting itself. Dion announced in 2022 that she had stiff person syndrome, an autoimmune neurological condition that causes progressive stiffness and severe muscle spasms. During a session with her physical therapist that was being filmed for the documentary, Dion has a seizure. The camera continued to roll throughout the medical crisis.

In an interview via video call on Monday, the director, Irene Taylor, discussed shooting the documentary and why Dion’s emergency was included in the final cut. These are edited excerpts from the conversation.

How far into preproduction did you learn about Dion’s illness?

I spoke with her at length, and I did not know she was ill. We were in the middle of the pandemic and I didn’t think twice about her being at home. Most of us were, and performers around the world were sort of out of commission temporarily.

We got to a place where we agreed to make the film. It was several weeks after that mutual decision that her manager asked me for a call. I figured it must be something serious because we got on the phone that day, and he told me that Celine was sick and that they didn’t know what it was. We were filming several months before there was a definitive diagnosis.

After getting the diagnosis, was the conversation on the table to stop filming?

Definitely not. When I realized that a) she had a problem with no name and b) when I actually started filming I could see how her body looked different, her face looked different, I was able to focus. The iris of my perspective got much smaller.

We are having trouble retrieving the article content.

Please enable JavaScript in your browser settings.

Thank you for your patience while we verify access. If you are in Reader mode please exit and  log into  your Times account, or  subscribe  for all of The Times.

Thank you for your patience while we verify access.

Already a subscriber?  Log in .

Want all of The Times?  Subscribe .

The Daily Show Fan Page

Experience The Daily Show

Explore the latest interviews, correspondent coverage, best-of moments and more from The Daily Show.

The Daily Show

S29 E68 • July 8, 2024

Host Jon Stewart returns to his place behind the desk for an unvarnished look at the 2024 election, with expert analysis from the Daily Show news team.

Extended Interviews

php while assignment in condition

The Daily Show Tickets

Attend a Live Taping

Find out how you can see The Daily Show live and in-person as a member of the studio audience.

Best of Jon Stewart

php while assignment in condition

The Weekly Show with Jon Stewart

New Episodes Thursdays

Jon Stewart and special guests tackle complex issues.

Powerful Politicos

php while assignment in condition

The Daily Show Shop

Great Things Are in Store

Become the proud owner of exclusive gear, including clothing, drinkware and must-have accessories.

About The Daily Show

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Warning: Assignment in condition

One thing that has always bugged me is that when checking my PHP scripts for problems, I get the warning "bool-assign : Assignment in condition" and I get them a lot.

For example:

Is there a different way to get multiple or all rows into an object or array? Or is there nothing wrong with this method?

  • coding-style
  • variable-assignment
  • conditional-statements

Peter Mortensen's user avatar

2 Answers 2

Try doing this instead:

I believe PHP is warning because of the $row = mysql_fetch_assoc($result) not returning a Boolean.

Jeremy Stanley's user avatar

  • 4 Actually, it's a code smell - PHP couldn't care less about the type of the result as long as it's not runtime convertible to false ("0",0, or false). Your script checker is just being paranoid because it's a common problem for rookies in languages with C-like syntax. –  Bob Gettys Commented Apr 6, 2009 at 17:46

Actually, I believe it's warning because you could be making a mistake. Normally in a conditional, you mean to do:

But it's easy to make a mistake and go:

So it's likely warning you. If PHP is anything at all like C, you can fix your problem with a set of parentheses around your statement, like so:

I believe Jeremy's answer is slightly off, because PHP is loosely typed and generally doesn't bother with such distinctions.

Dan Fego's user avatar

  • I believe our answers are both functionally identical; yours is effectively saying "while(($row = mysql_fetch_assoc($result)) === true)". I would argue that the "!== false" / "=== true" adds to the readability and reasoning for it working with/without the parantheses. –  Jeremy Stanley Commented Apr 5, 2009 at 6:00
  • Yes it's just a warning and works fine, however I was not sure if I was missing some alternative much simpler way (even though this way seems the simplest to me) Regards –  Moak Commented Apr 5, 2009 at 6:02
  • I was just addressing the specific warning at hand. It's warning him because there's an "assignment in condition", i.e. a = where it's generally expecting a ==. This just makes it see it as whatever the result from the parens is. –  Dan Fego Commented Apr 5, 2009 at 6:05

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged php mysql coding-style variable-assignment conditional-statements or ask your own question .

  • The Overflow Blog
  • Community Products Roadmap Update, July 2024
  • Featured on Meta
  • We spent a sprint addressing your requests — here’s how it went
  • Upcoming initiatives on Stack Overflow and across the Stack Exchange network...
  • Policy: Generative AI (e.g., ChatGPT) is banned
  • The [lib] tag is being burninated
  • What makes a homepage useful for logged-in users

Hot Network Questions

  • openssh-client/openssh-server show different version than ssh -V
  • Why Nähe is a noun in this sentence?
  • Why does the Egyptian Hieroglyph M8 (pool with lotus flowers) phonetically correspnd to 'Sh' sound?
  • y / p does not paste all yanked lines
  • Cliffhanger ending?
  • Why is a game's minor update on Steam (e.g., New World) ~15 GB to download?
  • What type of interaction in a π-complex?
  • Plane to train in Copenhagen
  • Why should I meet my advisor even if I have nothing to report?
  • As an advisor, how can I help students with time management and procrastination?
  • Do United paid upgrades to first class (from economy) count for PQP PQF stuff?
  • Did any 8-bit machine select palette by character name instead of color memory?
  • Did the BBC censor a non-binary character in Transformers: EarthSpark?
  • Who first promoted the idea that the primary purpose of government is to protect its citizens?
  • Help with "Roll XD12, and keep each middle dice as an individual result"
  • Why is Uranus colder than Neptune?
  • What is the connector name for this 820 μF 450 V Nichicon capacitor
  • Are US enlisted personnel (as opposed to officers) required, or allowed, to disobey unlawful orders?
  • Can you arrange 25 whole numbers (not necessarily all different) so that the sum of any three successive terms is even but the sum of all 25 is odd?
  • Which part(s) of this proof of Goodstein's Theorem are not expressible in Peano arithmetic?
  • Do thermodynamic cycles occur only in human-made machines?
  • Sitting on a desk or at a desk? What's the diffrence?
  • Can the US president kill at will?
  • Why does the Trump immunity decision further delay the trial?

php while assignment in condition

IMAGES

  1. PHP Do While Loop

    php while assignment in condition

  2. PHP While Loop

    php while assignment in condition

  3. php tutorial

    php while assignment in condition

  4. PHP While Loop

    php while assignment in condition

  5. While Loop in PHP

    php while assignment in condition

  6. PHP while loop

    php while assignment in condition

VIDEO

  1. PHP while loops explained

  2. PHP while loop #coding #php #shortsfeed2024 #while #trending #trendingshorts

  3. PHP eCommerce 6

  4. [Tutorial] PHP variable

  5. PHP If…Else, if...else...elseif Statements

  6. how to define a variable and assign value to variable in PHP, declare variable in PHP and value

COMMENTS

  1. while loop in php with assignment operator

    while loop in php with assignment operator. Ask Question Asked 12 years, 11 months ago. Modified 12 years, 11 months ago. ... Which will get evaluated as false in the while condition, causing the loop to terminate. Share. Follow answered Jul 13, 2011 at 15:22. Jeff Lambert ...

  2. PHP Conditional Operator: Examples and Tips

    Conditional Assignment Operator in PHP is a shorthand operator that allow developers to assign values to variables based on certain conditions. In this article, we will explore how the various Conditional Assignment Operators in PHP simplify code and make it more readable. Let's begin with the ternary operator. Ternary Operator Syntax

  3. PHP while

    Introduction to the PHP while statement. The while statement executes a code block as long as an expression is true. The syntax of the while statement is as follows: statement; How it works. First, PHP evaluates the expression. If the result is true, PHP executes the statement. Then, PHP re-evaluates the expression again.

  4. PHP: while

    The basic form of a while statement is: statement. The meaning of a while statement is simple. It tells PHP to execute the nested statement (s) repeatedly, as long as the while expression evaluates to true. The value of the expression is checked each time at the beginning of the loop, so even if this value changes during the execution of the ...

  5. PHP: Assignment

    Assignment Operators. The basic assignment operator is "=". Your first inclination might be to think of this as "equal to". ... An exception to the usual assignment by value behaviour within PHP occurs with object s, which are assigned by reference. Objects may be explicitly copied via the clone keyword. Assignment by Reference.

  6. PHP Control Structures and Loops: if, else, for, foreach, while, and

    This can be achieved easily using the break keyword. It will get you out of the current for , foreach , while , do-while, or switch structure. You can also use break to get out of multiple nested loops by supplying a numeric argument. For example, using break 3 will break you out of 3 nested loops.

  7. Mastering PHP While Loop

    The PHP while loop is a powerful tool for developers. It enables the execution of a block of code repeatedly as long as a certain condition is true. The while loop is an essential component in PHP, which is used to automate and simplify the process of executing repetitive tasks. Understanding PHP While Loop

  8. PHP While, Do-While, For and Foreach Loops

    Difference Between while and do…while Loop. The while loop differs from the do-while loop in one important way — with a while loop, the condition to be evaluated is tested at the beginning of each loop iteration, so if the conditional expression evaluates to false, the loop will never be executed.. With a do-while loop, on the other hand, the loop will always be executed once, even if the ...

  9. PHP: if

    if. ¶. The if construct is one of the most important features of many languages, PHP included. It allows for conditional execution of code fragments. PHP features an if structure that is similar to that of C: statement. As described in the section about expressions, expression is evaluated to its Boolean value.

  10. An Essential Guide to PHP if Statement with Best Practices

    The if statement allows you to execute a statement if an expression evaluates to true. The following shows the syntax of the if statement: statement; Code language: HTML, XML (xml) In this syntax, PHP evaluates the expression first. If the expression evaluates to true, PHP executes the statement. In case the expression evaluates to false, PHP ...

  11. PHP While Loop

    The condition in the while loop can be any expression that returns a boolean value (true or false). The code block within the curly braces {} is executed repeatedly as long as the condition is true. Syntax while (condition is true) { The code that needs to be executed; } One of the advantages of the while loop is its flexibility.

  12. PHP While Loop: Iterating Through Code Blocks

    Condition: This is the Boolean part evaluated before each iteration of the loop. Code Block: It is the curly braces {} part that contains the repeated block of code. Anyway, let's see how the while loop works in PHP. How the While Loop Works in PHP? Check the following figure you will see the full task for the PHP while loop.

  13. PHP Assignment Operators

    Use PHP assignment operator ( =) to assign a value to a variable. The assignment expression returns the value assigned. Use arithmetic assignment operators to carry arithmetic operations and assign at the same time. Use concatenation assignment operator ( .= )to concatenate strings and assign the result to a variable in a single statement.

  14. PHP if Statements

    PHP Conditional Statements. Very often when you write code, you want to perform different actions for different conditions. You can use conditional statements in your code to do this. In PHP we have the following conditional statements: if statement - executes some code if one condition is true

  15. PHP IF Statement: A Guide to Conditional Logic

    The IF statement in PHP checks whether a condition is true, allowing the script to perform different actions based on this check. Here's a concise summary of the key points discussed: The IF statement evaluates a condition. If the condition is true, it executes the code block within the curly braces {}. If the condition is false, the code ...

  16. PHP

    The syntax of while loop in PHP is similar to that in C language. The loop body block will be repeatedly executed as long as the Boolean expression in the while statement is true. The following flowchart helps in understanding how the while loop in PHP works −. The value of the expression is checked each time at the beginning of the loop.

  17. Unable to get Approver for po as condition based in Assignment and

    Hello Experts, I am facing issue while approving po based on condition applied in Assignment and approval screen ,please have a look to the screenshot attached with it , do i have missed something in mapping. When Order total is >100 2.When order total is >1000. 3.When order total is >10,000

  18. Why would you use an assignment in a condition?

    The reason is: Performance improvement (sometimes) Less code (always) Take an example: There is a method someMethod() and in an if condition you want to check whether the return value of the method is null. If not, you are going to use the return value again. If(null != someMethod()){. String s = someMethod();

  19. 'I Am: Celine Dion' Director Talks About Capturing the Star's Seizure

    Irene Taylor, director of the new documentary "I Am: Celine Dion," talks about the decision to include a grueling scene of the pop star in crisis.

  20. The Daily Show Fan Page

    The source for The Daily Show fans, with episodes hosted by Jon Stewart, Ronny Chieng, Jordan Klepper, Dulcé Sloan and more, plus interviews, highlights and The Weekly Show podcast.

  21. php

    It's warning him because there's an "assignment in condition", i.e. a = where it's generally expecting a ==. This just makes it see it as whatever the result from the parens is. - Dan Fego