by Froosh » 09. April 2023 14:26
Interesting. I was curious, and tried on my system and got a small square with the incorrect color. I inspected the generated html, and explicitly set the height and width of the element, and that showed that no image was actually generated by the php code provided.
A bit of digging let me to other samples on the PHP site, and the ones I tried did not work either. One of the samples, a HTML page using PHP and imagecreate() generated a PHP fatal error. Following that error message led to a stackoverflow post that indicated to check php.ini and ensure "extension=gd" line is not commented out, which in my install was the case. I also noticed that my Apache error.log indicated that imagecreate was not found.
After uncommenting that "extension=gd", and restarting Apache, I know see blue 150x150 square and text.
As Nobbie mentioned, there could be other causes in your particular situation. The logs are your friend, especially if you are running code based on an example that might be masking the underlying error.