PHP Notice:  Undefined property: stdClass::$TrackDetails in /app/vendor/fedex/SoapTrackClientStatus.php on line 58

PHP doesn’t mind very much if you try to access a missing property (member variable) from an object. It just throws you an E_NOTICE and returns NULL, confident that your logic will properly handle its falsey nature.

But much like it’s cousin error “Trying to get property of non-object”, it can wreck havoc when you’ve failed to prepare for them

Breach of Contract

I ran into this example while looking at an old implementation with the FedEx API (this isn’t their API code, it was a client implementation) for tracking shipments. …


PHP Notice:  Undefined offset: 0 in /app/cottenio/cron/repair_malformed_messages.php on line 812

Undefined offset errors are the integer-based cousins to the string-based Undefined indexes errors, and like a bad penny they always seem to turn up.

Still, since the “Undefined” family of errors are all E_NOTICE events you might not even notice them affecting the logic of your code unless you’re wary enough to be looking for them.

Integer Based Issues

Reminder: array keys in PHP can either be an integer or a string, and “Undefined offset” errors imply an index access with an integer

Here’s an example of a mysterious, hand-crafted XML-parser utility function…


PHP Notice:  Trying to get property of non-object in /app/cottenio/core.php on line 1175

PHP is like a kindly old aunt who doesn’t like to correct the young’ins even though she knows they’ve done wrong.

In her head, she’s saying “Oh, so-and-so, that’s so cute,” while in her head she’s sadly contemplating the genetic lottery that led someone to try to fetch an object property from a variable that isn’t an object at all.

So when you see this error in your code just know you’ve either made terribly incorrect assumptions about your incoming data, or that you’re accessing an object…


PHP Deprecated:  Function set_magic_quotes_runtime() is deprecated in /app/oldapp/etc/class.phpmailer.php on line 1091

Do you believe in ghosts?

Because PHP has ghosts. Terrible specters that haunt the darkest corners of your clients’ legacy projects, just waiting… quietly, patiently, for you to do something reasonable like trying to upgrade the project to a newer version of PHP.

And then?

FATAL ERROR.

All because what was once deprecated is now dead.

And of all my favorite deprecated functions to run into when evaluating old projects for a conversion to the newest version of PHP, there’s nothing quite like “magic quotes.”

A Terrible Idea

Magic quotes were a…


PHP Notice:  Undefined index: reciept_email in /opt/cottenio/core.php on line 331

There are many errors in PHP that are like siblings: undefined variable, undefined property, and undefined index for instance — and they all range in severity based on circumstance. Some are like the quiet wallflowers at the school dance nobody notices, while others are deadly killers just waiting to ambush your unsuspecting users.

Whereas the undefined variable error is fairly fast to diagnose (seek out the line reported and see if its simply misspelled or never initialized), the undefined index error might require a deep dive into an entire chain…


PHP Notice:  Undefined variable: inactive_sohps in /app/cottenio/core.php on line 567

PHP is extremely permissive about undefined variables, unlike static typed languages like C.

So permissive, in fact, that an undefined variable isn’t classed at the level of Error or Warning, but of Notice instead.

Why?

Because an undefined variable in PHP is temporarily replaced with its default value if it hasn’t been assigned yet¹.

How Undefined Variables Work

First, how do we prove that the PHP interpreter only does a temporary replacement? How do we know it doesn’t initialize the variable with its default value after its first encounter with it?

The code…


The infamous hacking of high-profile Twitter accounts on July 15th, 2020 yielded a group of crypto-scammers over $117,000 worth of Bitcoin in a few short hours. Join us on the trail to find out where the money came from and where it’s going, along with a few clues that may give authorities a means to track down the cyber-criminals, including an analysis of the indictments of

(This article is being updated as new information about the hackers becomes available.)

No, Elon Musk is NOT Giving Away Free Bitcoin

Twitter got hacked: big time.

And — thank our lucky stars — rather than start a nuclear war or crash the…


An article covering the many issues that may occur when utilizing manual tagging of UTM parameters in SEM advertising campaigns; their discovery and cataloging with Python. Presents case examples of a merchant managing their own advertising platforms and utilizing UTM parameters to determine the customers’ experience (discounts, shipping options, etc).

If you’re already familiar with how UTM parameters, manual tagging, and Google/Bing ad platforms work just skip down about halfway to see the Python code build-out.

Photo by Pixabay from Pexels

“Something is wrong with my ad-spend.”

Terrifying words. Expensive words.

Adwords.

Or, in this example: Bing Ads.

The Scenario

A client has an e-commerce website that…


Photo by Christina Morillo from Pexels

Today I was working on my 2020 plan to turn things into AWS Lambdas.

Better put: hopefully only the things I should turn into Lambdas. You know, the sorts of things that don’t really need a cloud server sitting around being billed by the hour when a microservice could handle the job on-demand.

The particular feature stack I was working on involved relying on a custom Region service that could look up US/Canadian postalcodes and provide a variety of information about them: alternate city names, latitude/longitude — you get the idea.

Our own custom data is glommed onto the standard…


Photo by Tomasz Filipek from Pexels

Tim Cotten

An enthusiast about most things technical and natural. <tim@cotten.io> @cottenio

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store