Posted (Updated ) in PHP

If you’ve ever come across the infuriating error

htmlspecialchars(): Invalid multibyte sequence in argument

I have a simple solution for you: Turn display_errors on in your php.ini file!

It turns out there’s a weird bug that doesn’t appear to be getting fixed any time soon that causes htmlspecialchars() to display this error only when display_errors is set to Off.

See this post for further details and a very big thank you to the Andy Young for writing it and saving me (and I’m sure many others) alot of time!

Read More »

Posted (Updated ) in PHP

There is a bug in some version of PHP causing large integers to print in scientific notation. Here’s how to replicate:

<?php
	$i = 6395360031312041;
 
	echo $i; //Outputs: 6.39536003131E+15

There is a quick and easy fix for this – simply number_format your integer whilst printing like so:

<?php
	$i = 6395360031312041;
 
	echo number_format($i, 0, '.', ''); //Outputs: 6395360031312041

This issue has been fixed in the latest version of PHP 5.2 (as of the time of writing that’s PHP 5.2.12).

Read More »