PHP Logo

Install PHP Mcrypt extension on CentOS 6 in 3 Supper Easy Steps

The php-mcrypt extension is not available on CentOS 6 or RHEL 6 (with/without…

The php-mcrypt extension is not available on CentOS 6 or RHEL 6 (with/without Parallels Plesk 11) although some applications such as Magento or phpMyAdmin require it to work properly.
We can easily install it though from the Fedora Project repositories or any other repository that include php-mcrypt.

1. Download the following RPM pacakges by using wget command:

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/php-mcrypt-5.3.3-1.el6.x86_64.rpm
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm

2. Install them using YUM:

yum localinstall php-mcrypt-5.3.3-1.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm

3. Reload Apache server to load the extension up:

service httpd restart

Server

FIX: Plesk and Sendmail Problem PHP

From the command line, enter this below. /usr/local/psa/bin/domain -u yourdomain.com -mail_service false…

From the command line, enter this below.

/usr/local/psa/bin/domain -u yourdomain.com -mail_service false

You do not need to restart the server. This tells Plesk to not use the mail server to send mail for that domain. It will then go through the correct MX entry for the domain and send it to an external domain. Specially for those who use Google Apps on Plesk.

You will need to do this for every domain hosted on the server.

Joomla

Use joomla default recaptcha plugin in Your Component or Module

1) Get reCaptcha keys from http://www.google.com/recaptcha 2) Set these keys to reCaptcha…

1) Get reCaptcha keys from http://www.google.com/recaptcha

2) Set these keys to reCaptcha plugin and activate it if it’s not.

3) Put below code where you want to show reCaptcha

//php code
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1');
//html code inside form tag
<div id="dynamic_recaptcha_1"></div>

4) Put this code where you validating/processing the form

$post = JRequest::get('post');
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);
if(!$res[0]){
die('Invalid Captcha');
}

PHP Logo

String Variables in PHP

String variables are used for values that contains characters. In this chapter…

String variables are used for values that contains characters.

In this chapter we are going to look at the most common functions and operators used to manipulate strings in PHP.

After we create a string we can manipulate it. A string can be used directly in a function or it can be stored in a variable.

Below, the PHP script assigns the text “Hello World” to a string variable called $txt:

<?php
$txt="Hello World";
echo $txt;
?>

The output of the code above will be:

Hello World

Now, lets try to use some different functions and operators to manipulate the string.

PHP Logo

Variables in PHP

Variables are used for storing a values, like text strings, numbers or…

Variables are used for storing a values, like text strings, numbers or arrays.

When a variable is declared, it can be used over and over again in your script.

All variables in PHP start with a $ sign symbol.

The correct way of declaring a variable in PHP:

$var_name = value;

New PHP programmers often forget the $ sign at the beginning of the variable. In that case it will not work.

Let’s try creating a variable containing a string, and a variable containing a number:

<?php
$txt="Hello World!";
$x=16;
?>

PHP Logo

Basic PHP Syntax

A PHP scripting block always starts with <?php and ends with ?>.…

PHP Logo
PHP Logo

A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.

On servers with shorthand support enabled you can start a scripting block with <? and end with ?>.

For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.

<?php
?>

A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.

Below, we have an example of a simple PHP script which sends the text “Hello World” to the browser: