473,473 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using global var (global settings?)

Hi all!

I have an app which reads from certain servers, but I'd like to have
them in am ini-file.

I made this up, but I need those vars to be visible in functions
too.... how do I do that?

BR
Sonnich

// default ini values
$dir1="\\\\server1\\finance";
$dir2="\\\\server2\\design\\";
// read in settings
$ini=fopen("config.ini", "r");
while(!feof($ini))
{
$line=fgets($ini, 100);
if(stristr($line, 'dir1') == TRUE)
{
$dir1=strstr($line, '=');
$dir1=trim(substr($dir1, 1, 1000));
}
else if(stristr($line, 'dir2') == TRUE)
{
$dir2=strstr($line, '=');
$dir2=trim(substr($dir2, 1, 1000));
}
}
fclose($ini);

Jun 19 '06 #1
1 1224
On 19 Jun 2006 09:56:17 -0700, "Sonnich" <so************@elektrobit.com> wrote:
I have an app which reads from certain servers, but I'd like to have
them in am ini-file.

I made this up, but I need those vars to be visible in functions
too.... how do I do that?


Various options, some of which are:

(1) Access the configuration values through functions instead of globals.
(2) Define them as constants; they're always in scope.
(3) Use the "global" statement in the function.
(4) Reference the variables through $GLOBALS.
(5) It sounds like you want to register your own superglobals - this is not
trivial; runkit can do it, but that's fairly magic and unlikely to be installed
on most servers. http://www.php.net/manual/en/runkit.sandbox.php
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jun 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: BillG | last post by:
I have a solution that has 3 projects in it. A web application called USITracking. A project library holding my business logic classes and a project library holding my data logic classes. From...
5
by: Dennis C. Drumm | last post by:
Is there one place (local xml file, registry, etc.) that all user can read and write to?? I have some settings that applicable to all users, but when a restricted rights user start my...
0
by: Arjen | last post by:
Hi, I use form authentication for my asp.net 2.0 webapplication. When a user request a page it must first load some settings. These settings will be placed inside the context.items. I can add...
2
by: Brian Henry | last post by:
What all can i do with these two files? i know a little about them but never really used them that much, is there any good resources for asp.net out there on them? thanks
15
by: Mark Goldin | last post by:
I have main aspx page with a number of user controls. How can I create a global property that will be visible in every user control? Thanks
2
by: rcp | last post by:
Hi all, I've read all posts from all existing threads and none of them worked to solve my problem, although its exactly the same. I'll try to explain my case and see if a kind soul could help me...
3
by: seb | last post by:
Hi, I am writing to a file some basic information using the logging module. It is working but in the log file some line are printed several time. I had put some print debugging messages in the...
4
by: Al Santino | last post by:
Hello, I've created a simple C# web services project using Visual Studio 2005. My service compiles and runs correctly when called by remote clients. I'm able to step through the service in the...
5
by: t f | last post by:
Hi Okay this should be a simple one... In my solution i have 2 projects (one class library and one control library) - they both share the name default namespace - question is I want to be...
4
by: =?Utf-8?B?SlA=?= | last post by:
I have a C# DLL project I have created. The DLL plugs into other C#.NET applications. This DLL has several classes and methods comprised for 4 namespaces that are used by other programmer to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.