jones
jones

Reputation: 661

get variable from one page

I'am a newbie also my language maybe bad, and looking for solution for my learning php code let say i have many page i.e. etc page1.php ... page1001.php each page maybe: inside of page1.php:

$color = "red";
$pages = "two";
$theme = "ocean";
$lang = "eng";
$charset = "ISO-8859-1";
etc (more..)

inside of page2.php :

$color = "blue";
$pages = "two";
$theme = "ocean";
$lang = "it";
$charset = "UTF-8";
etc (more..)

now i need to put the variable of each pages to one page, n just put a simple code in each pages to setting them so next time easily to edit, note I using plain text (flat file)

anybody help me? i give appreciate and say thank you

Upvotes: 0

Views: 193

Answers (4)

Tilo Mitra
Tilo Mitra

Reputation: 2793

Judging by your data, you could put your values for a certain page into an associative array such as this:

//Page1.php
$page1Information('color' => 'red', 'pages' => 'two', 'theme = 'ocean');

//Page2.php
$page2Information('color' => 'blue', 'pages' => 'five', 'theme = 'forest');

Then you can include all the pages in your parameter.php file, and call upon the data in any one file by going:

echo $page1Information['color']; 
//Prints out "red"

Upvotes: 0

jones
jones

Reputation: 661

oh sorry maybe i give wrong explained:

I mean all content in page1.php up to page1001.php above i will move to one page call it as parameter.php so parameter.php become:

<? 
//the value of page1.php 
$color = "red"; 
$pages = "two"; 
$theme = "ocean"; 
$lang = "eng"; 
$charset = "ISO-8859-1"; 
etc (more..)

//the value of page2.php : 
$color = "blue"; 
$pages = "two"; 
$theme = "ocean"; 
$lang = "it"; 
$charset = "UTF-8"; 
//etc (more..) 

//the value of page3.php :
$bla-bla = "bla-bla";
?>

now how to call the value of page1.php also page2.php in parameter.php above? if i using include "parameter.php"; in each page (page1.php up to page1001.php) sometimes not suitable to each of page...

Upvotes: 0

SpaghettiMonster
SpaghettiMonster

Reputation: 620

or you could use:

require('page1.php');

This will work similarly, but cause an error if the page cannot be located.

see: here

Upvotes: 0

tensaix2j
tensaix2j

Reputation: 462

You can try to use "include"

Upvotes: 1

Related Questions