Jump to content

Calling a local PHP file


williamZanelli

Recommended Posts

Hi guys,

 

I'm grappling with a small issue I have.

 

I need to call a local PHP file, from inside another PHP file..

 

Some for example, I would like to call the file modeule.php, using the 2 variables.. from inside max.php.

 

max.php

<?php
//required to call the module.php
/module.php?var1=xyz&var2=abc

?>

What the best way of achieveing this?

Thanks

Will

Link to comment
https://forums.phpfreaks.com/topic/161889-calling-a-local-php-file/
Share on other sites

You cant pass vars via include() as for as i know

 

the cURL im working on at min is for a working google map geo query so i have just copied and pasted but changed the URL

 

<?php
$url = $_SERVER['PHP_SELF'] . "modeule.php?var1=xyz&var2=abc"; // make this the direct path to the file
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$data = curl_exec($ch);
curl_close($ch);
?>

 

This will return a string in to the $data var but you will need to set up your modeule.php file to return the data.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.