Priti's Technical Corner

March 21, 2013

PHP Array Index and Constant

Filed under: PHP, PHP 5.3 Certification, PHP Array — Tags: — pritisolanki @ 5:30 am

I asked following question in my training to explain some point.

Consider following

define(‘Message’,’name’);

$arr[1]=’Hello’;
$arr[‘Message’]=’World’;
$arr[‘name’]=”Jhon”;

echo $arr[1].$arr[Message];

Answers Received :

Hello World
Hello name
Hello Jhon

One question and multiple answers ! The right answer is “Hello Jhon” . Does it tickle your brain? why ! .

Please notice there is no single quote around string index – “Message” in $arr[Message] . And, “Message” is a defined constant which is initialized to “name” and $arr[‘name’] is Jhon :).

Above example explains why we should always provide single quotes to string index.

 

 

 

March 13, 2013

PhpMyAdmin Error – The mysqli extension is missing. Please check your PHP configuration [CentOs]

Filed under: Apache, CentOS, Mysql, PHP — Tags: , — pritisolanki @ 6:09 am

Recently , I came across with following error on a CentOS6 machine on my colleague’s  machine.

 The mysqli extension is missing. Please check your PHP configuration…

As I was sure about my installation I started looking for a possible fix on google. I checked the output of phpinfo ()  and found there is no lib related to mysqli. After trying all option and no luck  I thought of trying from starting hence I run following command in terminal.

php -m | grep –i mysqli

I noticed I don’t have mysqli install !. Run following command

yum install php-mysql

It will install the “php-mysql” as per repository set on CentOS.

service httpd restart

service mysql restart

Refresh the url http://localhost/phpmyadmin page received a pop up to enter username/password ..but with some reason at my end password was incorrect so I did following

mysqladmin -u root password NEWPASSWORD

This time it worked for me :).

Create a free website or blog at WordPress.com.

%d bloggers like this: