Tag Archives: wamp
I was having some trouble on a WAMP installation when trying to cURL an encrypted site over port 443. The cURL response was not helpful at all, it was as follows: [url] => https://encrypted.google.com/ [content_type] => text/plain;charset=utf-8 [http_code] => 200 [header_size] => 229 [request_size] => 170 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.027 [namelookup_time] => 0 [connect_time] => 0.002 [pretransfer_time] => 0.004 [size_upload] => 0 [size_download] => 227 [speed_download] => 8407 [speed_upload] => 0 [download_content_length] => 227 [upload_content_length] => 0 [starttransfer_time] => 0.027 [redirect_time] => 0 After quite a bit of researching, I found that the problem was related to checking the certificate. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); The aforementioned fix works, but it is sort of quick-and-dirty. If you’d like to know the proper way to fix this, you’d need to use the CURLOPT_CAINFO option. See this post for details.
Here are a few tips for those of you who’d like to write good code in PHP: Set up a Development Server Set up a development server or sandbox. Don’t write, test, or develop code on a production server. If you are a *nix user, you probably already have a LAMP environment on your own computer. If you are a Windows user, try XAMPP or WAMPSERVER (personal favorite). If you are on mac, try MAMP. As you develop your PHP, you will need to be learning about the environment which it runs in, and the settings that will affect your code and/or application. This is a journey, so don’t expect to master it all at once. You will get into things like virtual hosts, .htaccess files, rewrite rules, and file permissions. Turn on Error Reporting At least, on your development server. On your production site, turn off displaying errors, but have them sent to a file. Check this file periodically as it will show you what unexpected things are happening in your code. Do’s and Don’t’s Don’t use short codes. They take longer to type, but PHP will be moving away from them in future versions. Also, the <? syntax can be mistaken for XML. Examples of short codes include <? instead of <?php, and also the syntax <?= $var ?> which is the easy way of writing <?php echo $var; ?> Do use comments and document your code. Don’t use a closing ?> at the end of your PHP files. … Continue reading