How can a php class read from a properties file?

This is a discussion on How can a php class read from a properties file? within the PHP Language forums, part of the PHP Programming Forums category; I have a class that calls some web services. I did not want the url of the web services to ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-11-2008
Anthony Smith
 
Posts: n/a
Default How can a php class read from a properties file?

I have a class that calls some web services. I did not want the url of
the web services to be hardcoded in the class. What is the best way to
go about doing this?
Reply With Quote
  #2 (permalink)  
Old 01-11-2008
Jerry Stuckle
 
Posts: n/a
Default Re: How can a php class read from a properties file?

Anthony Smith wrote:
> I have a class that calls some web services. I did not want the url of
> the web services to be hardcoded in the class. What is the best way to
> go about doing this?
>


Set the url as a property and initialize it via the constructor or a set
function (or give the ability to do both).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #3 (permalink)  
Old 01-13-2008
Peter Pei
 
Posts: n/a
Default Re: How can a php class read from a properties file?

property
Reply With Quote
  #4 (permalink)  
Old 01-15-2008
Rob
 
Posts: n/a
Default Re: How can a php class read from a properties file?

On Jan 11, 9:24*pm, Anthony Smith <mrsmi...@hotmail.com> wrote:
> I have a class that calls some web services. I did not want the url of
> the web services to be hardcoded in the class. What is the best way to
> go about doing this?


Anthony, you could do this in a similar way to .Net, by using an
application configuration file.

The file can then be read in using parse_ini_file() -
http://uk.php.net/manual/en/function.parse-ini-file.php

The same thing is sometimes done by storing configuration details in a
database, and reading those in at runtime.

Rob.
Reply With Quote
  #5 (permalink)  
Old 01-15-2008
Anthony Smith
 
Posts: n/a
Default Re: How can a php class read from a properties file?

On Jan 15, 7:45 am, Rob <ratkin...@tbs-ltd.co.uk> wrote:
> On Jan 11, 9:24 pm,AnthonySmith<mrsmi...@hotmail.com> wrote:
>
> > I have a class that calls some web services. I did not want the url of
> > the web services to be hardcoded in the class. What is the best way to
> > go about doing this?

>
> Anthony, you could do this in a similar way to .Net, by using an
> application configuration file.
>
> The file can then be read in using parse_ini_file() -http://uk.php.net/manual/en/function.parse-ini-file.php
>
> The same thing is sometimes done by storing configuration details in a
> database, and reading those in at runtime.
>
> Rob.


Thanks Rob. Exactly what I was looking for.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:59 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0