What are the advantages and disadvantages of using PHP for generating graphics compared to SVG?

One advantage of using PHP for generating graphics is that it allows for dynamic and data-driven graphics to be created easily. However, PHP lacks the scalability and flexibility of SVG, which is a vector-based graphics format that can be easily scaled without loss of quality.

// Example PHP code for generating a simple graphic using GD library
$width = 200;
$height = 200;

$image = imagecreatetruecolor($width, $height);
$bg_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 0, 0);

imagefill($image, 0, 0, $bg_color);
imagestring($image, 5, 50, 50, "Hello, PHP!", $text_color);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);