TIME NOW
World current time now,
CALENDAR
Calendar monthly, yearly
login GOLD PRICE, RATE
login HOROSCOPE
login DICTIONARIES, LISTS
login SCIENCE EDUCATION RELIGION
login FINANCE, BUSINESS
login WORLD COUNTRIES, WIKI

PHP scripts, code, examples, tutorial

Previous articlePage bottomNext article  ALL TOPICS

PHP. SEO script example - 1. title, keywords, languages

 The example changes <TITLE> according $_GET variables. This file is main. Multilanguage are controlled via $_SESSION. $_GET['op'] variable
controls SEO elements.

DOWNLOAD: _files/zip/php_seo_code_example_1.zip

inndex.php:

<?php
session_start();

global $_SESSION, $_GET, $_POST;
global $i;

include "eventConfig.php";
include "eventViews.php";

//echo " 0 $lang {$_SESSION['lang']} <BR>";
if (($_GET['lang'] <> $_SESSION['lang']) and !$_GET['lock'])
    $_SESSION['lang'] = $_GET['lang'];

//echo " 1 $lang {$_SESSION['lang']} <BR>";
$lang = $_SESSION['lang'];

//echo " 2 $lang {$_SESSION['lang']}<BR>";
if (!$_SESSION['lang'])
    $lang = $_SESSION['lang'] = "en-GB";

//echo " 3 $lang {$_SESSION['lang']}<BR>";

$_LANG = $_LANG[$lang];

extract($_CONFIG);
extract($_LANG);
extract($_GET);

echo "  test ", $op - 1, " default title = $titleDefault uA = $uA , uB = $uB<BR>";
$title = "{$uA[$op - 1]} {$uB[$op - 1]} {$uC}";

if (!$op)
    $title = $titleDefault;

$title = "<TITLE>$title</TITLE>";

$content = "<DIV style = \"width: 400px\" >LANG: " . mainLang() . "<BR>" . mainMenu() . "<DIV style = 'float: right;'>Keys:" . mainSeoBox() . "</DIV><BR clear=both> $lang</DIV>";



$content = "$top$title$mid$content$bot";

print $content;

echo "<pre>";
print_r($_LANG);
print_r($_SESSION);

?>
 

View functions eventViews.php:
<?php

function mainLang()
{
    
    $content .= "<A href = \"?lang=lt-LT\">[LT]</A> \n";
    $content .= "<A href = \"?lang=en-GB\">[EN]</A><BR>\n";
    
    return $content;
    
}

function mainMenu()
{
    
    global $_LANG, $_POST, $_CONFIG;
    extract($_LANG);
    //echo "<pre>"; print_r ($_LANG); echo "</pre>";
    global $i; // = 0;
    $i = 0;
    foreach ($mainMenu as $k => $v) {
        
        //$content .= "<A href = \"?$k&uA={$uA[$i]}&uB={$uB[$i]}&lock=1\">$v</A><BR>\n";
        $content .= "<A href = \"?$k&lock=1\">$v</A><BR>\n";
        $i++;
    }
    
    return $content;
}

function mainSeoBox()
{
    
    global $_LANG, $_POST, $_CONFIG;
    extract($_LANG);
    //echo "<pre>"; print_r ($_LANG); echo "</pre>";
    $v = $seoBox[$_GET['op']];
    
    $seoArr = explode(",", $v);
    
    foreach ($seoArr as $kk => $vv) {
        $fontSize = rand(11, 16);
        $content .= "<H3 style = \"width: 200px; display: inline; font-size: {$fontSize}px;\"><A href = \"http://www.google.lt/#hl=lt&q=$vv\">$vv</A></H3><br>\n";
    }
    
    
    return $content;
}

?>

Configuration file eventConfig.php:
<?php

$_CONFIG = array(
    
    "top" => "<?xml version=\"1.0\" encoding=\"utf-8\"\?\>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"lt\" lang=\"lt\">
<head>\n<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\" />",
    
    "mid" => "\n</head><body>",
    
    "bot" => "\n</body><html>"
    
);

$_LANG = array(
    
    "en-GB" => array(
        
        "titleDefault" => "News WOrld Internet Seo",
        
        "mainMenu" => array(
            "op=1" => "News",
            "op=2" => "Internet",
            "op=3" => "Weather",
            "op=4" => "SEO",
            "op=5" => "Quizzes"
        ),
        
        "uA" => array(
            "News:",
            "Internet:",
            "Weather:",
            "SEO:",
            "Quizzes:"
        ),
        "uB" => array(
            "About everything",
            "IT help",
            "In europe",
            "SEO",
            "About everything"
        ),
        
        "seoBox" => array(
            "HOme",
            "About, About, About",
            "IT service, IT help, IT, IT lessons",
            "Weather, Weather forecast, Weather in Europe",
            "SEO, Seo help, SEO tips",
            "About, About, About"
        ),
       
        
    ),
    
    "lt-LT" => array(
        
        "titleDefault" => "Naujienos Pasaulis Internetas Seo",
        
        "mainMenu" => array(
            "op=1" => "Naujienos",
            "op=2" => "Internetas",
            "op=3" => "Orai",
            "op=4" => "SEO",
            "op=5" => "Testai"
            
        ),
        "uA" => array(
            "Naujienos:",
            "Internetas:",
            "Orai:",
            "SEO:",
            "Testai:"
        ),
        
        "uB" => array(
            "Pradžia",
            "Apie viską, viskas, visiems, visur",
            "IT pagalba, IT servisas, IT, IT pamokos",
            "Oras, orai, Orų prognozė",
            "SEO, Seo pamokos, SEO pagalba",
            "Apie viską, viskas, visiems, visur"
        ),
        
              
    )
    
);

?>
 
 
Previous articlePage topNext article  ALL TOPICS


Guest:
Hello

Usually seo parameters are taken from database, combining with mod_rewrite rules in.htaccesss


2013-06-07 11:13:21

 Use username: Guest, Anonymous, Programmer






QUOTES:
Nothing will benefit human health and increase the chances for survival of life on Earth as much as the evolution to a vegetarian diet.
Albert Einstein
A heart that loves is always young.
Greek Proverb
Marlene, I don't think it's acceptable to set fire to your guests.
Jen