All,
I'm coming from java and coldfusion, where one can set a "global" variable
in one place (the servletcontext in java, Application.cfm in coldfusion) and
all files in that site can then take advantage of these variables without
the need to "include" a variables page in every page on the site.
Is there something comparable in php, like an Application.php or some such
thing?
One more question that's basically an extension of the first. in
development, my site is http://localhost/mysite, but in the hosting
environment, it's http://mysite
Now, let's say I have a "header" include that includes images in it, and
that header is included in multiple directory trees, so relative pathing of
those images isn't possible. Is there a preferred way in php for dealing
with this kind of thing, since i can't simply use /images/myimage.jpg since
that path isn't valid in the local environment?
Thanks for any answers. I'm doing some emergency work on a php site as a
favor to a friend and am quite out of my element.
Marc 4 2997
Marc E wrote:
All,
I'm coming from java and coldfusion, where one can set a "global" variable
in one place (the servletcontext in java, Application.cfm in coldfusion) and
all files in that site can then take advantage of these variables without
the need to "include" a variables page in every page on the site.
Is there something comparable in php, like an Application.php or some such
thing?
Not really. But why would you need it? In several years of PHP
programming I never have - but then in general globals are not a good
thing, anyway, IMHO.
One more question that's basically an extension of the first. in
development, my site is http://localhost/mysite, but in the hosting
environment, it's http://mysite
Why isn't it http://localhost? That's what I use. Or, even http://example (the real site being http://example.com) by using your
HOSTS file.
Now, let's say I have a "header" include that includes images in it, and
that header is included in multiple directory trees, so relative pathing of
those images isn't possible. Is there a preferred way in php for dealing
with this kind of thing, since i can't simply use /images/myimage.jpg since
that path isn't valid in the local environment?
Check out $_SERVER['DOCUMENT_ROOT'] will always point to the root
directory of your site. From there on you can use a path relative to
your document root directory - if you use the above format.
Thanks for any answers. I'm doing some emergency work on a php site as a
favor to a friend and am quite out of my element.
Marc
I'd suggest you get someone more familiar with PHP to help you. I think
you're on the wrong track here.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Jerry Stuckle wrote:
Marc E wrote:
> Is there something comparable in php, like an Application.php or some such thing?
Not really. But why would you need it? In several years of PHP
programming I never have - but then in general globals are not a good
thing, anyway, IMHO.
I follow the old Microsoft model - using INI files. I even use
the same file format, and write my own set/get routines for them.
Thanks for the quick response Jerry.
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:YJ******** *************** *******@comcast .com...
Marc E wrote:
>All, I'm coming from java and coldfusion, where one can set a "global" variable in one place (the servletcontext in java, Application.cfm in coldfusion) and all files in that site can then take advantage of these variables without the need to "include" a variables page in every page on the site. Is there something comparable in php, like an Application.php or some such thing?
Not really. But why would you need it? In several years of PHP
programming I never have - but then in general globals are not a good
thing, anyway, IMHO.
Why need it? For the same reason that java servlets have Filters...becau se
it's a heck of a lot easier to be able to route all requests through
interceptors that handle specific functionality. For example, authentication
handling. i'd rather have an AuthFilter (or comparable functionality in a
coldfusion Application.cfm file) through which every request runs that
contains all the logic for ensuring a user is logged in and, if not, routed
to the appropriate page. Seems to me that if I want this type of
functionality in PHP, I have to have an include at the top of each page.
For this rinky dink site i'm doing this quick work for, it's not a big
deal..... just annoying and time wasting IMHO.
>
>One more question that's basically an extension of the first. in development, my site is http://localhost/mysite, but in the hosting environment, it's http://mysite
Why isn't it http://localhost? That's what I use. Or, even http://example (the real site being http://example.com) by using your
HOSTS file.
it's not localhost because i have dozens of other sites on this machine,
with each site as a subdirectory under the root. never thought of using
hosts file before.
>
>Now, let's say I have a "header" include that includes images in it, and that header is included in multiple directory trees, so relative pathing of those images isn't possible. Is there a preferred way in php for dealing with this kind of thing, since i can't simply use /images/myimage.jpg since that path isn't valid in the local environment?
Check out $_SERVER['DOCUMENT_ROOT'] will always point to the root
directory of your site. From there on you can use a path relative to your
document root directory - if you use the above format.
that one didn't work for me. my normal doc root for all coldfusion
development is in my cfusionmx\wwwro ot directory, and that's the site that's
configured as the base in IIS. but for this php stuff, i've got everything
in inetpub\wwwroot , and have virtual directories set up for it. but
Document_Root is returning the cfusionmx\wwwro ot directory. good thought
though!
>
>Thanks for any answers. I'm doing some emergency work on a php site as a favor to a friend and am quite out of my element.
Marc
I'd suggest you get someone more familiar with PHP to help you. I think
you're on the wrong track here.
Tell me about it brother. I'm so used to java and coldfusion cfcs that
coming back to regular old scripting is very foreign.
i've found php remarkably simple to learn, especially thanks to the
incredible documentation. it's just one or two things i'm coming across that
are slipping me up.
>
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
Marc E wrote:
Thanks for the quick response Jerry.
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:YJ******** *************** *******@comcast .com...
>Marc E wrote:
>>All, I'm coming from java and coldfusion, where one can set a "global" variable in one place (the servletcontext in java, Application.cfm in coldfusion) and all files in that site can then take advantage of these variables without the need to "include" a variables page in every page on the site. Is there something comparable in php, like an Application.php or some such thing? Not really. But why would you need it? In several years of PHP programming I never have - but then in general globals are not a good thing, anyway, IMHO.
Why need it? For the same reason that java servlets have Filters...becau se
it's a heck of a lot easier to be able to route all requests through
interceptors that handle specific functionality. For example,
authentication handling. i'd rather have an AuthFilter (or comparable
functionality in a coldfusion Application.cfm file) through which every
request runs that contains all the logic for ensuring a user is logged in
and, if not, routed to the appropriate page. Seems to me that if I want
this type of functionality in PHP, I have to have an include at the top of
each page. For this rinky dink site i'm doing this quick work for, it's
not a big deal..... just annoying and time wasting IMHO.
That doesn't really answer Jerry's question in the context of PHP.
BTW assuming you mean globals applying to the whole website (or application
if you prefer) you can use autoprepend to reference the file instead of
explicitly including it - but you loose a lot of transparency and
flexibility.
BUT YOU ARE NOW WRITING IN PHP. Don't load code you don't need. If you use
the autoloader PHP will find the files and load them.
>>One more question that's basically an extension of the first. in development , my site is http://localhost/mysite, but in the hosting environment , it's http://mysite Check out $_SERVER['DOCUMENT_ROOT'] will always point to the root directory of your site. From there on you can use a path relative to your document root directory - if you use the above format.
that one didn't work for me. my normal doc root for all coldfusion
development is in my cfusionmx\wwwro ot directory, and that's the site
that's configured as the base in IIS. but for this php stuff, i've got
everything in inetpub\wwwroot , and have virtual directories set up for it.
but Document_Root is returning the cfusionmx\wwwro ot directory. good
thought though!
You seem to be digging yourself a hole here.
The right solution is to understand how the include_path works and set it up
for your requirements.
C. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David |
last post by:
Hello.
I am looking for advice on what is "best practice" regarding looping
through a form to check its checkboxes and associated data fields.
Here is what I am trying to do (Here is the page I am working on:
http://www3.telus.net/thothworks/LinLeastSqPoly4.html).
I provide a form for a user to enter up to twenty (M = 20) data pairs.
The user need not enter data for all twenty pairs, but
the user must indicate that data is present by...
|
by: Mark Twombley |
last post by:
Hi, I'm just getting back into C++ and had a question about the best
practice for assigning error numbers.
I have been working in VB for sometime now and there you would start
assigning error number at vbObjectError + count.
Is there a similar practice in C++ or is it just coder preference.
Thanks
--
Mark Twombley
|
by: David WOO |
last post by:
Hi,
I am a newbie on C++, I need to define some global variables which should be
accessible to most classes. In the mean time, I don't won't the global
variables be modified freely at most of these classes. I know there is a
pattern called singleton can more or less do such a trick. I am wondering is
this the best way to do it (regarding the convenience and safety), as this
is such a fundamental thing, I believe most of you have a say...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: Woody Splawn |
last post by:
I am finding that time after time I have instances where I need to access
information in a variable that is public. At the same time, the books I
read say that one should not use public variables too much - that it's bad
programming practice. Is there an easy way to deal with this? I would like
to do things in the "Best Practices" way but at the same time I don't want
to make a federal case out of it.
This comes up over and over...
| |
by: Jay Wolfe |
last post by:
Hello,
I'm trying to make sure I use best practices (and hence save myself some
headaches) with the declaration and definition of global variables. Let's
say I have an app with 30 files, including main.cpp I have global
variables that need defining in main.cpp and declaring in all other files
in. The way I've seen it done is to define/declare everything in one header
file (e.g. globalincludes.h) prefaced with the word EXTERN
...
|
by: csgraham74 |
last post by:
Hi guys,
Basically i have been developing in dotnet for a couple of years but
ive had a few issues in regards to error handling.
For example - I have a class that i call passing in a stored procedure
and connection string as a path. My method returns a dataset. In my SP
i have an output parameter which tells me whether the SP select is
successful or not. If i get a error code passed back then i throw an
exception this then returns...
|
by: Nemisis |
last post by:
Guys,
I would like to write a error handler, or something, that will allow
me to write to a database when an error occurs on my site. I am
trying to implement this in the global.asax file a the moment, but am
having problems when a 404 error occurs, i cant access sessionstate.
Is writing this code in the global.asax file the best way to do this?
I have been searching on the net and hear alot about httphandlers?
Will a httphanlder...
|
by: =?Utf-8?B?bWFya203NQ==?= |
last post by:
I have a simple page i'm trying to do dynmaically.. i have a page called
submitcomments.aspx with the .cs codebehind..
before i created everything in design view.. now i've ripped that out and
added a asp panel to the page and created a procedure in my c# datalayer.cs
file called drawsubmitcomments
in that procedure i create the text boxes and buttons.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |