Jump to content

Hey again, this time I need help function with global vars.


ShaKeD

Recommended Posts

Hey, I`v a problem. I`m using include function.

 

include 'lang.php';

 

now I want to use all of the variables that exist in lang.php ..

the problem is that I`m using functions on my index.php file, and I don't want to enter the function every time with those variables.

 

how can I fix it?

 

 

10x.

Link to comment
Share on other sites

Make the variables in the lang.php constants.

 

IE:

 

//lang.php

<?php
// insetad of
$my_welcome_text = "Welcome Home!";

//use
define('MY_WELCOME_TEXT', 'Welcome Home!');
?>

 

That way it is available to every function, class etc as long as it is included.

Link to comment
Share on other sites

I used $lang as array

 

lang.php

-

 

$lang[blah] = ' blah ' ;

$lang[blaas] = ' blah sadf';

 

index.php

-

include 'lang.php';

$_GLOBALS['lang']  = $lang;

 

but when I`m using $lang inside my functions it doesn't work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.