You are here: Re: Getting variables from another file « PHP Programming Language « IT news, forums, messages
Re: Getting variables from another file

Posted by �rjan Langbakk on 12/17/62 11:56

Den 14.08.2006 22:41, skriblet mootmail-googlegroups@yahoo.com følgende:
> Ørjan Langbakk wrote:
>> And, as I am also new to the array-functions, how would I go around
>> creating that file, and pulling the different values from it?
>>
>> I'm thinking I could use something like:
>>
>> <?php
>> $prices = array (
>> product1 => 1200,
>> product2 => 2400,
>> product3 => 3450,
>> )
>> ?>
>>
>
> To do this, put that $prices array in a file all by itself.
> Then, from the page that needs to use this data, use require_once [1]
> to include the file.
> To access the data for a specific product, then, you would say, for
> example, $prices['product1'].
>
> This can be a very easy to implement solution, but difficult to
> maintain in the long run. I agree with those advocating using, at the
> very least, CSV (though I've never done it, so probably won't be of
> much help). Once someone decides they want to do more with the website
> and/or the data, you are going to wish you had a more flexible data
> backend than an include file with an array.
>
>
> [1] - http://us2.php.net/manual/en/function.require-once.php

Hm. Well, I got it to work, but not as I wanted to. Okey, the file
prices.php and the require_once all work fine, but since I already
include a CSV-file with all the specific details about each product, I
need the <?php echo $prices['product1']; ?> to be _in_ the CSV file I
parse - and THAT seems to be a problem, since the code just shows up in
the page source code, it's not being parsed, and I wonder how I can
correct this?

--
mvh
Ørjan Langbakk
http://www.bergenpchjelp.no
http://www.cubic-design.net

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация