473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

[PHP4] accessing constants outside class body

Is there a way to see the value of a constant that is defined outside of the
class body from within the class?

I need to do something like this, but it isn't working:

// in one file I define these settings
define('_DBUSER_', 'me');
define('_DBPASS_', 'secret');
define('_DBHOST_', 'localhost:3306');
define('_DBNAME_', 'mydb');

// then include this file in the file with the class definition
include('settings.inc');

class DBWrapper
{
var $dbuser;
var $dbpass;
var $dbhost;
var $dbname;

function DBWrapper()
{
$this->dbuser = _DBUSER_;
$this->dbpass = _DBPASS_;
$this->dbhost = _DBHOST_;
$this->dbname = _DBNAME_;
}

// ...
}
thank you,
..soma
Dec 21 '05 #1
2 1711
Hi.

This example code have to be working. I allways use code constructions
like this.

--Are you sure that your .inc code begin with '<?php ' and ends '?>'.

--Another one error that can be here is the path to *.inc file. You can
don't see warnings by apache configuration ("php_value error_reporting
7" for example) but really that file not found and don't including. Try
to check path to that *.inc file.

Sorry for my inglish and best regards.

Dec 21 '05 #2
Thanks, turns out I was doing something wrong - that code I posted DOES
work...

..s
Dec 22 '05 #3

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

Similar topics

2
by: Joshua Beall | last post by:
Hi All, What does the "const" reserved word in PHP4 do? I know it is a reserved word in PHP4, but the only references I can find to it are for PHP5. Here's what I want to do: Rather than...
4
by: jsnX | last post by:
Say I would like my namespace to have some constants associated with it, like this: ========== ===== namespace broadpen { struct defaults { static const double w = 10.0; static const double...
14
by: John Ratliff | last post by:
I'm trying to find out whether g++ has a bug or not. Wait, don't leave, it's a standard C++ question, I promise. This program will compile and link fine under mingw/g++ 3.4.2, but fails to link...
5
by: Cyril Gupta | last post by:
Hello, I have a class inside another class. The Scenario is like Car->Engine, where Car is a class with a set of properties and methods and Engine is another class inside it with its own set of...
7
by: hummh | last post by:
Hello out there, I´m making my first steps with ASP.NET 2.0 and have he following problem: I´ve implemented a Web User Control that sits in the root of my ASP.NET Website. I want to use the...
6
by: PC | last post by:
Gentlesofts, Forgive me. I'm an abject newbie in your world, using VB 2005 with the dot-Net wonderfulness. So, I'm writing a wonderful class or two to interface with a solemnly ancient...
3
by: xhe | last post by:
I have just upgraded my php version form php4 to php5. and I met this problem, and don't know if you know the solution. My site was written in PHP4, and most parts can be running smoothly in PHP5,...
12
by: Gordon | last post by:
I want to provide a set of static functions in a superclass that work with class constants defined in a decendant of that class. Unfortunately I've run into a snag with this idea. Example: ...
2
by: Alex Weber | last post by:
weird issue i ran into today... its possible to define case-insensitive constants outside the scope of a class using: define('name', 'value', false); however, you cannot use define() for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.