Thursday, May 2, 2019

Dynamic PHP variable


PHP allows you to use dynamic variable names, called variable variables. You can name a variable with the value stored in another variable. That is, one variable contains the name of another variable.


$Bangladesh = 147570;
$dhaka = 11500;
$cityname = "Bangladesh";
echo "The size of $cityname is ${$cityname}";
$cityname = "dhaka";
echo "The size of $cityname is ${$cityname}";
The output from this code is
The size of Bangladesh is 147570
The size of dhaka is 11500

Ref: https://www.dummies.com/programming/php/how-to-use-php-variable-variables/

Saturday, January 19, 2019

Install phpmyamin in Raspberry Pi

First, install MySQL which is a free opensource database system.

sudo apt install mysql-server php-mysql
The PHPMyAdmin installation is pretty quick and easy, we simply have to use the packet manager with this command :
sudo apt install phpmyadmin
but here we're going to install phpmyadmin in a another way. go to phpmyadmin website then download as zip. unzip the copy to var/www/html path.

After install mysql go cmd to set new password for root
sudo mysql_secure_installation   
 [to set new pass type none then entry new password]

To login mysql go cmd and type
sudo mysql -p -u root 
Then add new super user to access phpmyadmin
set password for user esteemsoft
CREATE USER ‘esteemsoft’@’%’ IDENTIFIED BY ‘password’ 
GRANT ALL PRIVILEGES ON *.* TO  ‘esteemsoft’@’%’ WITH GRANT OPTION;
Done!!! now go to localhost/phpmyadmin and enjoy....

Thursday, August 9, 2018

Handling undefined & null parameters in JavaScript

Here with a given example is enough to make it understand


 function foo(DivID, color) {  
   if (!color) { // the correct test here should be 'typeof color == "undefined"'  
     color = "green";  
   }  
   DivID.style.backgroundColor = color;  
 }  
 foo(div_color, "red"); //set the background color to red  
 foo(div_color); //set the background color to the default green  
 foo(div_color, "");​ //remove the background color !This will fail!  

Total Pageviews