Deprecated Warning : Assigning the return value of new by reference is deprecated in * on line *

Hey there,

Did you get this Warning/Notice? :

Deprecated Warning : Assigning the return value of new by reference is deprecated in *  on line *

In PHP5 this notation is deprecated

$obj =& new Class();

That would generate the warning but ‘&’ is not required and can be removed.

$obj = new Class();

To see why this was used in PHP4, see  http://www.php.net/manual/en/oop4.newref.php

Cheers,

JENSon.




PHP Warning: file_get_contents(): Unable to find the wrapper “https” – did you forget to enable it when you configured PHP?

Hey Folks,

Warning: file_get_contents(): Unable to find the wrapper “https” – did you forget to enable it when you configured PHP?

Got the above warning? No Problems. You can get rid of this warning by just enabling php_openssl.dll extension in your php.ini [For eg. xammp/php/php.ini] configuration file. [If you’re not seeing php_openssl.dll itself in your php.ini, just directly add the extension line to the php.ini configuration file]

Your php.ini file :

;extension=php_oci8_11g.dll
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll

You just need to uncomment the line extension=php_openssl.dll.

It should look like below :

;extension=php_oci8_11g.dll
extension=php_openssl.dll
;extension=php_pdo_firebird.dll

If the extension itself does not exist, You have to add extension=php_openssl.dll to your php.ini file. (Provided you’ve the proper dll file bundled with your windows PHP environment (I’m using XAMPP & the dll extension is php_openssl.dll.)

Note : I’m using XAMPP for Windows

Cheers,
JENSon.

PHP : Deleting Duplicates From An Array

Hey Folks,

PHP’s array_unique function allows you to remove duplicate values from an array.

Syntax:

<?php
$arr = array("a" => "Ford", "Mercedes", "b" => "BMW", "Lotus", "Ford", "Renault");
$result = array_unique($arr);
echo "<pre>";
print_r($result);
echo "</pre>";

/* Output
Array
(
    [a] => Ford
    [0] => Mercedes
    [b] => BMW
    [1] => Lotus
    [3] => Renault
)
*/
?>

Note : The keys are preserved. array_unique() sorts the values treated as string at first, then will keep the first key encountered for every value, and ignore all following keys. It does not mean that the key of the first related value from the unsorted array will be kept.

Cheers,
JENSon.