Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.