Hey, can anyone link me to an easily understood php include tutorial, how to target it =)
Printable View
Hey, can anyone link me to an easily understood php include tutorial, how to target it =)
What do you mean, how to target it?
ORPHP Code:<?php
include "file.php";
?>
OrPHP Code:<?php
include ("file.php");
?>
OrPHP Code:<?php
include 'file.php';
?>
orPHP Code:<?
include "file.php";
?>
PHP Code:<?
include ("file.php");
?>
orPHP Code:<?
include 'file.php';
?>
PHP Code:<?
$page = file_get_contents($page);
echo $page;
?>
Lol, one way would of been good enough :P
I know I was just bored and wanted to show all the ways to include something :P
Denta, I know how to include a file but how to target the include like so when you click on 'News' the include changes from including the main to 'news'
google it ?
You could just use the $_GET function
If i understood you, thats what you mean.PHP Code:<?php
$page = $_GET['page'];
switch($page){
default:
include('main.html');
break;
case "news":
include('news.html');
break;
}
?>
You'd go to
index.php?page=news
to load news.html
or just index.php
to load main.html
If you mean change the included page without page load, you'd have to use AJAX.
yeah, that's it, thomas :) thanks! would I have to edit any of that code?
Well you'd obviously have to put it in the right part of your layout code and to add another page to it you would change it to:
PHP Code:<?php
$page = $_GET['page'];
switch($page){
default:
include('main.html');
break;
case "news":
include('news.html');
break;
case "anotherpage":
include("anotherpage.html");
break;
}
?>