Analogous to docblock annotations, attributes make it possible to apply metadata to a class, function, or property with a native syntax and reflection API. The original
<<Attr>> syntax accepted for PHP 8.0 had several shortcomings which were addressed by changing the syntax to
@@Attr. Now there is a new proposal to borrow Rust’s
#[Attr] syntax instead. In this post I examine the main arguments for this change and why I still believe the
@@ syntax is best.
On March 16, 2015, something amazing happened in the world of PHP. The long-awaited, hotly debated Scalar Type Declarations RFC was accepted for PHP 7! Finally, it will be possible to declare scalar types (int, float, bool, and string) for function parameters and return values: The need for safe type casts By default, scalar types… Continue reading PolyCast: a library for safe type conversion in PHP
Recently I was challenged with enabling users to drag and drop items in a list to sort them in any order, and persisting that order in a SQL database. One way to handle this would be to add an index column to the table, which could be updated when an item is reordered. The downside… Continue reading Implementing a linked list in SQL
As the Klingon ship bears down on the Starship Enterprise, preparing to fire a barrage of photon torpedoes, Captain Picard shouts “Maximum warp!” and the Enterprise leaps away towards another star system, faster than the speed of light. Is this scene from Star Trek purely science fiction, or is there truth to the concept of interstellar starships? Despite the significant scientific progress that has been made in this area, energy requirements, high costs, and the problem of time still present enormous challenges to the vision of interstellar travel as portrayed in Star Trek and other films.
I originally wrote this post last September as a research paper for my Business Ethics course at Rasmussen College. I decided to post it on my blog now since I still feel strongly about the issues of censorship and online privacy, especially in light of recent leaks about the NSA’s top-secret surveillance programs. What if… Continue reading Google, ethics, and Internet censorship
This post is based on a research paper I authored earlier this month as part of my General Psychology course at Rasmussen College. Have you ever been struggling with a website or application that is difficult or confusing to use, and thought, “This could be so much easier if it were designed differently”? You may… Continue reading Psychology in Interactive Web Design
If you’re reading this, you probably already know what a CAPTCHA is. The most common form consists of an image with warped or obscured characters which must be entered into a text field. While these image-based CAPTCHAs tend to be effective at stopping spam, they are also poorly accessible, often slow, and require a third-party… Continue reading Responsive Captcha: A small PHP library for preventing spam