in one word :if you set $purpose=0, you can use this function to verify certificate chain.
====================================================================
I want to verify a certificate chain. just like this:
userCert.pem => middleCert.pem => rootCert.pem
I figured that none of these openssl functions provide this function directly. And some friends have same need as me, "mikey at badpenguins dot com" even write his own code to verify certificate chain(you can see notes below openssl_verify).
and I notice a note which has '-3' likes below openssl_verify, it says "validating an X509 certificate chain in php seems to be possible with openssl_x509_checkpurpose()", and I read the source code about this function, the given constant var about $purpose (like X509_PURPOSE_SSL_CLIENT ) is 1-7, and if you set $purpose among 1-7, you cannot verify the cert chain. Set $purpose=0 can get the truly result about verify a cert chain.
and I give that '-3' note a thumb-up, now it has -2 , lol.