Click here to Skip to main content
15,891,629 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hello members..
i have a proplem in php
i tried to discover the mistake in this code but i can not
Who discovered the mistake, please tell me
#thanks

What I have tried:

PHP
$loopCond = true;
while($loopCond == true)
{
    echo"ok"
}

{
    $loopCond = false;
    echo "<p>And now it's done.</p>
}
Posted
Updated 9-Sep-17 1:59am
v2

I've updated your question to make your code easier to read and debug.

The braces are showing you where your mistake is. Your while loop is infinite. To fix:

PHP
$loopCond = true;
while($loopCond == true)
{
    echo"ok"
    $loopCond = false;
}
echo "<p>And now it's done.</p>

Please take the time to learn how to debug and step over your code. You will be able to see these simple logic mistakes. This article should help: How to Debug in PHP[^]
 
Share this answer
 
v2
Comments
ahmed20032003 9-Sep-17 8:08am    
thanks for you..
Use the debugger to see what your code is doing.

There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]
phpdbg | php debugger[^]
Debugging techniques for PHP programmers[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 
Comments
ahmed20032003 9-Sep-17 8:08am    
thanks for you..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900