Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

March 23, 2013

[SOLVED] Fixed PHP Warning: Module 'apc' already loaded in Unknown on line 0

You are getting this message "[SOLVED] Fixed PHP Warning:  Module 'apc' already loaded in Unknown on line 0"

every time you execute the php in your console.

It means that you have already activated the apc.so extension.

You must check the second module activation.

Here you can find the apc.ini config file
$ locate apc.ini 
/etc/php5/conf.d/20-apc.ini
/etc/php5/mods-available/apc.ini

Now locate php.ini files and check them for uncommented "extension=apc.so" line
$ locate php.ini
/etc/php5/apache2/php.ini
/etc/php5/cgi/php.ini
/etc/php5/cli/php.ini

check files for uncommented "extension=apc.so"
$ cat /etc/php5/apache2/php.ini | grep apc.so
;extension=apc.so

Here you found it
$ cat /etc/php5/cli/php.ini | grep apc.so
extension=apc.so

 

Edit the file
 sudo vim /etc/php5/cli/php.ini

and add ";" before "extension=apc.so"

save it and you are done

 

Source: http://blog.ciuly.com/my-server/php-warning-module-apc-already-loaded-in-unknown-on-line-0/

 

 

 

December 9, 2010

[SOLVED] PHP: Why 2 !=2 aka "never compare floating point numbers for equality"

“never compare floating point numbers for equality”.

The reason (19.6*100) !== (double)1960, is because inside a computer they are not equal.

Try this:

<?php

printf("%.15f", (19.6*100));

?>

Outputs: 1960.000000000000227 (not 1960 as somewhat expected)

If comparison is required a few options come to mind (other than BCMath):

1) Round numbers before comparison:

<?php

$sig_figs = 5;
echo (round((19.6*100), $sig_figs) !== round((double)1960, $sig_figs)) ? 'not equal' : 'equal';

?>

Outputs: equal

Source: php.net

July 27, 2010

[SOLVED] PHP: How upload file using cURL?


<?php
$request_url = ‘http://www.akchauhan.com/test.php’;
$post_params['name'] = urlencode(’Test User’);
$post_params['file'] =@.'demo/testfile.txt’;
$post_params['
submit'] = urlencode(’submit’);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
?>


Source: How upload file using cURL?.