“call to undefined function imagecreatetruecolor” error in PHP & pChart

后端 未结 6 1801
南旧
南旧 2020-12-30 19:41

I am trying to integrate \"pChart\" with my PHP code. When I am trying to run the samples it gives me an error stating call to undefined function imagecreatetruecolor<

6条回答
  •  猫巷女王i
    2020-12-30 20:06

    This answer is an update 9 years later, but PHP has changed a lot. Please upvote the St. Woland from which this is derived...

    Use the following code on your web server to test if you have GD extension:

    ".print_r($testGD,true)."
    "; //display GD function list

    If you get the message that it's not installed, then check the following steps:

    1. Look at the output of phpinfo() to identify your php.ini
    2. Edit php.ini and enable the GD extension:
      • Newer PHP (7.3, fg):
        • extension=gd2 //uncomment
      • Older PHP (5.x, 7.0, you should upgrade):
        • extension_dir= //uncomment or add
        • extension=php_gd2.dll //uncomment or add
    3. GD for 7.x may not be installed
      • (for Ubuntu like OS'es) sudo apt install php7.3-gd # replace version to yours
    4. Restart web server
    5. Run the test script again
    6. (Remove test script when all is working, it can be a security hole)

    As you can see the exact method is very version dependent. I hope this additional information can help others sort out the exact steps they might need.

提交回复
热议问题