PHP is a script language and interpreter that is
freely available and used primarily on Linux Web servers. PHP,
originally derived from Personal Home Page Tools, now stands for PHP: Hypertext Preprocessor, which the PHP FAQ describes as a "recursive acronym."
Latest Post
Showing posts with label PHP Learning. Show all posts
Showing posts with label PHP Learning. Show all posts
PHP Learning
Increase Max Execution Time With .htaccess file
Here I am going to write new shortcut, and I did research on it and gained that many people facing same problem that I faced.
Open .htaccess and add following code
thanks
Increase Max Execution Time:
There are many searching for it that how to increase max-execution-time of website. About billions of users are using CPanel and within Cpanel you are unable to change php.ini options. But if you have WHM or Root then you can do it easily but here we have to resolve this problem for our users.
When you are using PHP module then it is confirm that you are using apache system too. apache system mostly works with .htaccess file so you can easily edit your .htaccess file and you can play with php.ini file without having WHM, WHMCS, Root, VPS, Dedicated server.
Requirements
But your system PHP language should be updated, minimum requirement is 5.x.
How can you find your PHP language version.
Method:
Make a file name info.php and upload to your server like
domain.com/info.phpnow open this and search
PHP Versioncheck max execution time. Search
max_execution_timeIncrease Max Execution Time With .htaccess file:
Open .htaccess and add following code
900 Is about 15 minutes. you can change it according to your mind.<IfModule mod_php5.c>
php_value max_execution_time 900
</IfModule>
thanks
Labels:
PHP Learning
Download PHP Scripts,
PHP Learning
PHP | Detect User Browser Language
How to detect user browser language and how to use it in URL.
If you add this script above your file code.
Then url will be :
If you add this script above your file code.
Then url will be :
- www.domain.com/index.php?lang=en
- www.domain.com/index.php?lang=ar
- www.domain.com/index.php?lang=es
- www.domain.com/index.php?lang=fr
- www.domain.com/index.php?lang=hu
- www.domain.com/index.php?lang=ra
<?php
//Redirect by language
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if(!isset($_GET['lang']))
{
//Retrieve location, set time
if(!isset($lang))
{
header("location: ".$_SERVER['PHP_SELF']);
exit;
}
else
{
header("location: ".$_SERVER['PHP_SELF']."?lang=".$lang);
exit;
}
}
?>
Labels:
Download PHP Scripts,
PHP Learning
Download PHP Scripts,
PHP Learning
But we need to keep in mind some topics like
Convert XML to PHP Array | Multilingual + Country wise SEO URL Solution
Multilingual + Country wise SEO URL Solution:
Examplehttp://www.getacho.com/index.php?loc=pk&lang=enHere I did deep research that how can I use PHP for Multilingual websites?
But we need to keep in mind some topics like
- User IP Address Function
- User Language Function
- IP to XML
- XML to PHP Array Conversion
- URL Concept
- Language And Area codes concept
<?php
//Redirect by language
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$context = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));
//redirect by IP
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$ip = $_SESSION['ip'];
$data = file_get_contents("http://api.hostip.info/get_html.php?ip=".$ip."&position=true");
$arrayofdata = explode("\n", $data);
$country = explode(":", $arrayofdata[0]);
$count = explode(" ", $country[1]);
if(!isset($_GET['lang']) AND !isset($_GET['loc']))
{
//Retrieve location, set time
if(empty($count))
{
header("location: index.php?loc=us-en&lang=".$lang);
exit;
}
else
{
header("location: index.php?loc=".strtolower(trim($count[2],"()"))."&lang=".$lang);
exit;
}
}
?>
Labels:
Download PHP Scripts,
PHP Learning
PHP Learning
PHP | Website Validation Function
PHP Website Validation Function
function validate_web($input_web) { $input_web = preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $input_web); $input_web = trim($input_web); $input_web = htmlspecialchars($input_web); $input_web = stripcslashes($input_web); return $input_web; }
Labels:
PHP Learning