php.ini is a core file to handle the behavior of PHP and sometimes apache might not pick it and php might not be using and it will create problem.
To resolve this, just see the output of phpinfo first.
Just add the following code snippet in the php file and run it through your server
Then look of configuration file (php.ini) path, by default it would be /etc
If you don’t have the file php.ini in that mentioned directory, just look for related ones like php.ini.default or something and just copy that as php.ini and restart your apache.