while break continue else
- first: You have to enable shell_exec() from your server
- second: Write each of the the following Scripts in a separate .py-file within a folder named py
i = 1
while i < 6:
print(i)
i += 1
i = 1
while i < 6:
print(i)
if (i == 3):
break
i += 1
i = 0
while i < 6:
i += 1
if i == 3:
continue
print(i)
i = 0
while i < 10:
i += 1
if 6 <= i <= 7:
continue
print(i)
i = 1
while i < 6:
print(i)
i += 1
else:
print("i is no longer less than 6")
- third: Write the following Script in the corresponding .php-files
<?php
echo shell_exec("python py/while.py");
?>
- Result while if <= i <=x continue:
1 2 3 4 5 8 9 10
(note that number 6 and 7 are missing in the result)
▸ up