There is a hidden sixth argument: string pointing to a file where the contents of the signed message should be saved.
It is very important for verifying signed and encrypted messages from MS Outlook which uses opaque signing. After decrypting of message you will get another MIME envelope like this:
MIME-Version: 1.0
Content-Disposition: attachment; filename="smime.p7m"
Content-Type: application/x-pkcs7-mime; smime-type=signed-data; name="smime.p7m"
Content-Transfer-Encoding: base64
MIIM/QYJ...
Even if you use base64_decode() you will not get decrypted message but PKCS #7 object.
BTW: How to create opaque signed message like from MS Outlook? Switch off PKCS7_DETACHED flag (the last 0 does it):
openssl_pkcs7_sign(
"full_path_to_message_file",
"full_path_where_to_store_signed_message_file",
"file://full_path_to_my_public_certificate.pem",
array("file://full_path_to_my_private_key.pem", "password"),
array(),
0
);