General Community > Scripting Help

n00b php Question...

(1/7) > >>

Seph|roth:
Ok i hope someone can be bothered to explain this to me, it's a very basic php question i'm sure but i can't seem to figure it out  :(

i have a variable, say $a, that needs to be called in a file, let's say home.php. but $a is not in that file, instead it's located in another file, inc.php which is included in home.php.

But this doesn't seem to work, the variable doesn't show. Any idea's?

[Unknown]:
Put global $a; at the top of both files... that might work.

-[Unknown]

Seph|roth:
thanks, but that doesn't seem to work (or i'm doing something wrong  ;))

here's what i've got: index.php


--- Code: ---<?php global $titlePrefix; ?>
<?php include ("http://www.ultimateweapon.net/fgn/htmlhead.php"); ?>
<?php $title = "Home"; ?>
<link href="../style/fgn_site.css" rel="stylesheet" type="text/css" />
<title><?php echo "$titlePrefix" . "$title" ?></title>
</head>
--- End code ---

htmlhead.php

--- Code: ---<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php
global $titlePrefix;
$titlePrefix = "UltimateWeapon.net :: Fantasy Gaming Network :: ";
?>
--- End code ---

But the title only shows up as "Home", without the $titlePrefix

۞:
Firstly, you do dont need to start each line with <?php


--- Code: ---<?php 
global $titlePrefix;
include ("http://www.ultimateweapon.net/fgn/htmlhead.php");
$title = "Home"; ?>
<link href="../style/fgn_site.css" rel="stylesheet" type="text/css" />
<title><?php echo "$titlePrefix" . "$title" ?></title>
</head>

--- End code ---


will work.

۞:
My next question is, is it including the page? Test it by viewing the source and looking to see if


--- Code: ---<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
--- End code ---
is there.

Navigation

[0] Message Index

[#] Next page

Go to full version