Help with File Command

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Duelist
Forum Newbie
Posts: 1
Joined: Wed Nov 24, 2010 8:46 pm

Help with File Command

Post by Duelist »

I am new to PHP but I have a good background in C++. I am trying to make a simple real time rate calculator for an online shopping cart for calculating freight rates for shipping.

To make it simple for the third party creators of the shopping cart to switch over to my rate calculator I am trying to make it work like one they already use for a different freight company.

The shopping cart is using PHP and sends the data to the other RTR using the PHP File command as per below.

$myfile = file('http://...../ratecalc.asp?Pickup_Postcode='.$ourpostcode.'&Destination_Postcode='.$postcode.'&Country='.$country.'&Weight='.$weight.'&Service_Type='.$service.'&Length='.$length.'&Width='.$width.'&Height='.$height.'&Quantity='.$quantity);

The RTR sends the data back to $myfile as though it had opened a normal file.

The RTR uses ASP to do this but I do not have access to a server that will run ASP so I am hoping to emulate what they are doing using PHP.

I have tried to find how to do this online but am not having much luck.

Can I create a ratecalc.php file that will send data back to the file command in my original php file?

I did a trial just to see by creating ratecalc.php and putting a print statement inside and it obviously did not work. But it also came up with an error message saying that the file command could not access a stream so I am assuming that the ratecalc.php somehow has to create a file stream.

Thanks
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Help with File Command

Post by Jonah Bron »

Yes, you can do that. You can access the data (Pickup_Postcode, Destination_Postcode, etc) with $_GET. Then just echo out the result of the calculation (assuming that's what ratecalc.asp does).
Post Reply