Link Problem

A

Anonymous

Guest
Hello!

This is absolotely ok to use Includes. I think this is a best way.
But (to my mind) you can change your script to look this way:


Code:
......
<?php
$id=$_GET['id'];
if($id=='home') include 'home.php';
if($id=='story') include 'story.php';
if($id=='characters') include 'characters.php';
.......
if($id=='ginjiamano') include 'ginjiamano.php'; 
if($id=='hevn') include 'hevn.php';
?> 
...........

I mean that there is no need to write $id=$_GET['id']; before every IF.
And it this case it is better to use ' than " bacause it takes more time to parse " than '.

Or better than if (in your case) it is better to use SWITCH

Code:
switch ($id) {
    case 'ginjiamano':
        include 'ginjiamano.php'; 
        break;
    case 'hevn':
        include 'hevn.php';
        break;
    case ''characters'':
        include 'characters.php';
        break;
.......
}

Also if you must open pages from another site you can use CURL module:

Code:
    $ch = curl_init ("$path/show.php");

// Receiving data from Script

    $data=curl_exec ($ch);
    if (!$data){
	echo curl_error($ch);
    }


Bereza Nikita
Rapid Internet Development Department
E-mail: nike@alarit.com
Alar Information Technologies,
URL: http://www.alarit.com
 
cooldownguy86 said:
Hello all php pro
I am having some problem, when i type goto.php?id=home in my browser, the page that pops up uses the goto.php title which is GB' rather that the suppost home.php title which is home.Why?
Is there any better function than include to open a new page?
Below are my codes for goto.php.

the best way is
Code:
<?php 
 $id=$_GET['id'];  
  switch($id){
    case 'home':
      $fname='home.php';
      break;
    case 'story':
      $fname='story.php';
      break;
    default:
       $fname='index.php';
}
header("Location: $fname");
exit;
?>
 
Back
Top