if (isset($_GET['debug'])) {
if(boolval($_GET['debug']) ? true : false)
{
echo "Using Distribution Certificate";
stream_context_set_option($ctx, 'ssl', 'local_cert','cert.pem');
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
} else {
echo "Using Development Certificate";
stream_context_set_option($ctx, 'ssl', 'local_cert','certdevelopment.pem');
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
}
}else{
// Fallback behaviour goes here
echo "Fallback Call To Use Distribution Certificate";
stream_context_set_option($ctx, 'ssl', 'local_cert','cert.pem');
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
}
When my URL is https://localhost/index.php?debug=true
I want to use the Distribution Certificate. If it's false then use the Development Certificate.
If anything else is there then we use the Distribution certificate.
Unfortunately when my PHP script executes, it is always using the "Distribution Certificate". even when I set it to false. I think the "boolval" method is not working all the time.
Instead of
if(boolval($_GET['debug']) ? true : false)
You should compare the values using
if($_GET['debug'] == 'true')
This is because both "true" and "false" evaluate to true when cast to a boolean. Check the test cases in the manual for more examples.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.