PHP Exceptions: try, catch, throw and finally
try and catch, what the caught object knows, throwing your own, catch order, finally, custom classes โ and why catch (Exception) misses an Error.
Browse all posts filed under Web Development.
๐ Web Developmenttry and catch, what the caught object knows, throwing your own, catch order, finally, custom classes โ and why catch (Exception) misses an Error.
๐ Web DevelopmentDelimiters, character classes, anchors and capture groups โ the parts of PHP regex you actually use, and the one job you must never give it.
๐ Web DevelopmentTwo functions carry almost every API you will write. json_encode, json_decode, the array-or-object rule, and why a silent null is not an empty result.
๐ Web Developmentsetcookie() writes a header, not a variable, which is why the cookie you just set is not in $_COOKIE until the browser sends it back on the next request.
๐ Web Developmentdate() to print it, strtotime() to read it, DateTime to do arithmetic on it โ and the timezone setting behind most off-by-five-hours bugs.
๐ Web DevelopmentOne variable, a list of values, and the missing break that catches everybody once. PHP switch explained, plus loose comparison and PHP 8's match.
๐ Web DevelopmentForms, sessions, a database and hashing finally come together. Registration, login, a page only members can reach, and a logout that clears all three of the things a session leaves behind.
๐ Web DevelopmentFour habits you build into ordinary code: never let user input become SQL, never let it become HTML, never store a password, and never assume a request came from your own page. Each problem shown breaking, then fixed.
๐ Web DevelopmentEvery site repeats its header and footer on every page. include and require are how you write that markup once and pull it in everywhere โ with the four keyword variants and the path mistake that only shows up in production.