1

I am trying to work out how to call a function from an external PHP file.

So far I have this:

<?php

include("http://www.website.net/wp-content/plugins/monarch/monarch.php");

display_inline();

?>

The function display_inline(); returns a string of HTML/CSS.

Just need to know if you think the syntax is correct?

3
  • 1
    What happens when you try it? Did it work? Commented Jul 12, 2015 at 1:41
  • I first need to allow HTTP URLs on the server. It came back saying that I can't request a direct URL. Commented Jul 12, 2015 at 4:51
  • As you're accessing a file in a WordPress plugin, the chances are it has restrictions to make sure it can only be accessed by said WP install Commented Dec 20, 2015 at 23:08

1 Answer 1

1

Yes that syntax is correct, however if you are making the request to that external file, it's going to return whatever the output of the executed monarch.php file was. If the file is local you'll have access to the functions. Unlike how HTML includes a CSS file, on the local system the path used by PHP should be relative to the system and not the webroot. You shouldn't need to be cautious about this so go ahead and try it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.