Link Problem

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
nike
New php-forum User
New php-forum User
Posts: 7
Joined: Fri Sep 06, 2002 7:59 am
Location: Ukraine
Contact:

Sat Nov 23, 2002 3:02 am

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: Select all

......
<?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: Select all

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: Select all


    $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

mjr
New php-forum User
New php-forum User
Posts: 18
Joined: Fri Sep 27, 2002 6:35 am
Contact:

Sat Nov 23, 2002 3:57 am

cooldownguy86 wrote: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: Select all

<?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;
?>
With best regards,
Cyril Kobets
http://ebusiness-news.blogspot.com

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests