Re: PHP vs Apache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Jul 11, 2022, at 12:02 PM, paulf@xxxxxxxxxxxxxxxxx wrote:
> 
> Folks:
> 
> I have two PHP apps on the same (local) box. One handles financial
> transactions (A) and the other handles budgeting (B). I want B to query
> A for information for the budget. So I'm technically querying a remote
> PHP script from within a different "site" and PHP script on the same
> box. Like this:
> 
> http://localhost:8000/budget/get_expenses.php queries
> http://localhost:8000/finance/expenses.php
> 
> I hope that makes sense. I have "allow_url_fopen = On" in my php.ini.
> There are three ways I've seen to do this:
> 
> file_get_contents()
> fopen()
> curl*
> 
> Curl is complex, so I haven't tried it yet.
> I've tried file_get_contents() via the PHP development server. Doesn't
> work. Generates an error.
> I've tried fopen() on the PHP development server, but it too fails with
> the same error. The error looks like this:
> 
> [Mon Jul 11 14:45:26 2022] PHP Warning:
> fopen(http://localhost:8000/slowen/index.php): Failed to open stream:
> HTTP request failed! in /home/paulf/public_html/budget/test.php on line
> 7
> 
> The call to the "remote" script is on line 7 in test.php above.
> 
> Here's the wrinkle: fopen() works if I'm using the Apache server. 
> 
> For what it's worth, the script being queried should return a PHP array
> in JSON format. The box is an Arch current box.
> 
> Can anyone explain why Apache can do this, but PHP's dev server can't?
> 
> Paul

Hi;
Both are under the same domain and port. So you can just use require or include on
expenses.php from get_expenses.php. Though expenses.php will have to be readable.

I hope this helps
Jeff K



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux