How-the-else-if-works - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of How-the-else-if-works.php
- <?php
- if (true) {
- echo "only first" . PHP_EOL;
- } elseif (true) {
- echo "---";
- } elseif (true) {
- echo "---";
- }
- if (false) {
- echo "---";
- } elseif (false) {
- echo "---";
- } elseif (true) {
- echo "only last" . PHP_EOL;
- }
- if (var_dump("check 1") || false) {
- echo "---";
- } elseif (var_dump("check 2") || false) {
- echo "---";
- } elseif (var_dump("check 3") || false) {
- echo "---";
- } elseif (var_dump("check 4 and goes in") || true) {
- echo "In the last case" . PHP_EOL;
- }