I can run openssl_encrypt ($string, $method, $pass);
when I run it through php cmd. However when I run it via Apache http server it throw the following error:
Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in D:\...\lab.php:2 Stack trace: #0 {main} thrown in D:\...\lab.php on line 2
The problem was that apache wasn't installed completely and there was some missing files of it.
so I reinstalled the apache and problem was gone.