If you are looking forward to install SSH2, follow the link to do so. It works and save you a lots time.

http://cubiclegeneration.com/web-servers/installing-secure-shell2-ssh2-php-extension

if you experience any issue at these lines

gunzip libssh2-0.18.tar.gz

tar -xvf libssh2-0.18.tar.gz

Just remove the .gz from the end, would work.

Done.

htaccess issue with SEF URL in Joomla

On your developer box: You enabled SEF in Joomla by doing the following way:

1.rename htaccess.txt to .htaccess
2.Global Configuration -> SEO Settings (set yes to everything) and save it

Refresh your Joomla site
click on your site links - if the short url is working then everything is cool if NOT

open up your Apache config file and

add the following lines to your virtual host setup

        
AllowOverride all


save the config file and restart the apache.
DONE.

If you having trouble with your flash player in CentOS 5 ( 64 bits) then follow the link to make it work. I googled for help and found out this after a long time. It's good.

http://www.yqed.com/install-flash-player-10-centos-64-bits/

Enjoy your flash player.

isset, empty functions of PHP

Always pay attention to these functions.


$a = 0;
// isset() - treats $a as not empty
if(isset($a))
echo "a has ".$a;

// empty() - treats $a as empty

having trouble with empty() with the editor

if(empty($a))
echo "a has ".$a;


both functions will display "a has 0".

Reading a file into a string in PHP

If you'd like to get the entire content of a file into a string then follow the way



// have your filename with path
$file_name = "yourfilename.ext";
$content_string = file_get_contents($file_name);
echo $content_string; // will display the content


want to display total chars in the file?


echo strlen($content_string);


To read file into array.


// have your filename with path
$file_name = "yourfilename.ext";
$content = file($filename);
foreach($content as $content_row)
echo $content_row;


// checks postal code format L4X-1S9
$regex = '/[a-z][0-9][a-z][- ]?[0-9][a-z][0-9]$/i';
if( preg_match($regex, $zip) )
echo "Valid postal code";


// checks for 5 digit or 9 digit zip code or 12345-6789
// or 123456789
$regex = '/(^\d{5}$)|(^\d{5}-\d{4}$)|(^\d{9}$)/'
if( preg_match($regex, $zip) )
echo "Valid Zip code";

Passing a PHP array to Javascript

PHP array:


$fruits = array("Apple","Mango","Banana");

convert $fruits to Javascript array


echo 'var fruits = new Array("',join($fruits,'","'),'");';


The above statement will convert PHP array to Javascript array. This saves a lot of time.



Some Links (off programming)