Category Archives: Uncategorized

Passing a boolean through HTTP GET request

All GET parameters are strings in PHP. You can use filter_var() with FILTER_VALIDATE_BOOLEAN: $myVar = filter_var($_GET[‘myVar’], FILTER_VALIDATE_BOOLEAN);$myVar = filter_var($_GET[‘myVar’], FILTER_VALIDATE_BOOLEAN); Here is description for FILTER_VALIDATE_BOOLEAN: Returns TRUE for "1", "true", "on" and "yes". Returns FALSE otherwise.   If FILTER_NULL_ON_FAILURE is set, FALSE is returned only for "0", "false", "off", "no", and "", and NULL is […]

PHP Convert Boolean to String

You can convert a PHP boolean (true/false) into a string: $test_bool = var_export(filter_var($_GET[‘test_bool’], FILTER_VALIDATE_BOOLEAN), true);$test_bool = var_export(filter_var($_GET[‘test_bool’], FILTER_VALIDATE_BOOLEAN), true);

Certbot renew error: Missing webroot

If you get this error messsage while trying to renew the certs: – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – Processing /etc/letsencrypt/renewal/ – […]

PHP Curl slow with HTTPS SSL requests

A possible solution is to force IPv4 resolving: curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); And also disable SSL verifications: curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); If the error persists, Curl is not the problem. Probably there is a network issue.

Download OpenVPN 2.4.7 and TAP-Windows

From here you can download latest OpenVPN version: And from here you can download all latest stable versions: It includes also TAP-Windows versions.

How to Configure OVH Email POP3 with Thunderbird

When adding a new email address (OVH hosted) on Thunderbird: The red-removed part should be your website. Reference (Italian):

What is the Correct JSON Content-Type for HTTP Headers?

Many web services uses different content-type for JSON data, i.e: application/json application/x-javascript text/javascript text/x-javascript text/x-jsonapplication/json application/x-javascript text/javascript text/x-javascript text/x-json But what is the correct content type to use for JSON data? For JSON text you should use application/json (read more on RFC 4627). For JSONP (runnable javascript) with callback, use application/javascript. You should read also […]

PHP Notice: Undefined offset: 1 (Array)

How to fix PHP Notice: Undefined offset: 1? This PHP snippet will generate a “Undefined Offset” notice: $parts = explode(".", "aaaa");   $data = $parts[1];   print_r($data);$parts = explode(".", "aaaa"); $data = $parts[1]; print_r($data); This happens because $parts[1] is undefined. To fix this “Undefined Offset” notice just check if isset($parts[1]): $parts = explode(".", "aaaa");   […]

How to Find PHP.ini Location

Need to know where is located your PHP.ini file? Locate PHP.ini with Find The best way (in my opinion) is to use “find” to locate the php.ini: find / -name php.inifind / -name php.ini You should get something like this: /etc/php/7.3/fpm/php.ini /etc/php/7.3/cli/php.ini/etc/php/7.3/fpm/php.ini /etc/php/7.3/cli/php.ini So this way you will locate PHP.ini for both PHP7 FPM and […]

How to Enable Display of Errors in PHP

First edit your PHP.ini file to make sure display_errors is enabled: display_errors = ondisplay_errors = on Then if you changed this value, you’ll need to restart PHP7-FPM process: /etc/init.d/php7.3-fpm restart/etc/init.d/php7.3-fpm restart Additionally you may prepend these lines on your PHP script: error_reporting(E_ALL); ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1);error_reporting(E_ALL); ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1);