get php string from another file

Hey,
I’m kindda new to php. I’m on my way developing a web site.

Can anyone please tell me how to get string values from another php or txt file?

e.g.:-

*I want to show company name with a string like ‘$c_name’ in index.php , feedback.php and gallery.php
*If I can call string value from somewhere else (text.txt or text.php) I do not need to change the company name in all three php files above. I will only have to change the string value in text.txt file

How can I do this. Thanks in advance.

Hello,

am just beginner but i believe u just need to make
in all files which call '$c_name ’

[php]include “text.php”;
$_REQUEST[‘c_name’];
[/php]

I think will work.

Good luck.

[php][/php]

Hi there,

The best way to do what you want is to create a session on all pages of your site using PHP. You would do that by putting session_start(); on the top of all your pages and saving what you want to use on other pages as: $_SESSION[‘variable’] = “value”; You would then call the session variable as follows: $_SESSION[‘variable’].

Hope this helps.

Create a file ‘text.php’ and in there the code

[php]$c_name = ‘your company name’;[/php]

Then in your index.php include the code

[php]require_once ‘text.php’;
echo $c_name;[/php]

If you want to use the $c_name variable in a function then you have to use the global statement to do so.

[php]require_once ‘text.php’;
function show_company(){
global $c_name;
echo $c_name;
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service