Since the company is renting virtual space and using an IIS server, there are a number of problems when deploying PHP: For example, we encountered this problem yesterday: Deploying the Thinkphp Project under IIS, the CAPTCHA cannot be displayed
Here's how to generate the verification code:
//making a special method to implement CAPTCHA generation functionverifyimg () {//The following class verify did not include the introduction//Walk auto-load Think.class.php autoload () $config=Array ( ' Usenoise ' =false, ' imageh ' = 35,//Verification Code Picture height' Imagew ' = ' = ', ' fontSize ', ' = ', ' Fontttf ' and ' 4.ttf ',//captcha font, not set random get' Length ' = 4 ) //Verify number of code bits; $verify=New\think\verify ($config ); $verify-entry (); }
Then Apache under can, but under IIS is not, see the internet said the most is to get rid of the BOM head on it, but I use the UE to save without BOM header or not
Today finally solved:
Before generating the verification code: add Ob_clean
//making a special method to implement CAPTCHA generation functionverifyimg () {//The following class verify did not include the introduction//Walk auto-load Think.class.php autoload () $config=Array ( ' Usenoise ' =false, ' imageh ' = 35,//Verification Code Picture height' Imagew ' = ' = ', ' fontSize ', ' = ', ' Fontttf ' and ' 4.ttf ',//captcha font, not set random get' Length ' = 4 ) //Verify number of code bits; Ob_clean(); $verify=New\think\verify ($config ); $verify-entry (); }
OK, of course, these are on the premise of opening the GD library
Workaround to deploy the Thinkphp project under IIS, the CAPTCHA cannot be displayed