Skip to content

Instantly share code, notes, and snippets.

@daveh
Created June 2, 2020 13:31
Show Gist options
  • Save daveh/7149c589457bf2c4dc537dff288ea675 to your computer and use it in GitHub Desktop.
Save daveh/7149c589457bf2c4dc537dff288ea675 to your computer and use it in GitHub Desktop.
Why you should use curly braces in conditionals and loops (code to accompany https://youtu.be/dsu0ooy2hnI)
<?php
/*
if ( ! file_exists("input.txt"))
exit;
*/
/*
if ( ! file_exists("input.txt"))
echo "File not found\n";
exit;
*/
if ( ! file_exists("input.txt")) {
echo "File not found\n";
exit;
}
print "File found ok, open for processing etc.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment