If you are on linux, most of the time the php.ini is located at /etc/php5/apache2/php.ini, you can navigate there from command line and open the file with your favorite text editor.
You can edit with this command:
sudo gedit /etc/php5/apache2/php.ini
sudo leafpad /etc/php5/apache2/php.ini
sudo vi /etc/php5/apache2/php.ini
sudo nano /etc/php5/apache2/php.ini
But if you are using xampp on linux or windows, the location of php.ini is little bit different.
Xampp on windows:
Xampp on linux:
For mac users, most likely the location of php.ini is on /private/etc/php.ini
If you still can't find your php.ini, the best way is to use the phpinfo() function, if you run this function it will generate special page, in there look for 'Loaded Configuration File', it will display the location of the php.ini file on your computer.