Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
I want to get a variable from a php file. I've read, that you can use include 'mypage.php'; and then use the variable. But if I do that it loads the visual part from the other file too (html and css from <style> tag).
Other methods are also apreciated.
Kind regards.
I have the var $screen_name in file twitter/index.php and want to have it in create.php
Tried:
include 'twitter/index.php';
echo $screen_name;
If you include the PHP file, it will also do the output. But you can suppress it with output buffering.
ob_start();
include './mypage.php';
ob_end_clean();
echo $varFromMypage;
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I am trying to call an HTML file in a php file but cant really get any right answer.
I have tried:
<?php require/include('filename');>
as well as
readfile('filename');
Doesn't work. How do I do that?
If you are trying to get the html content inside a php file, you can change your .html file extension to .php and use include() or require().
Example, if you have a file named headings.html, rename it to headings.php and then use:
require('headings.php');
While require() will produce a fatal error if the file is not found, include() will only produce a warning.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a page 'Error 404' and the address is like http://myurl.com/error404
the php file of error404 require's the index.php to properly show it.
I need a php code that will load or show the content in the url above without redirecting/changing the url. thanks
echo file_get_contents("http://myurl.com/error404");
Works also for URLs.
DOCS
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I currently don't even know what exactly to search, don't know if that procedure has a name or something, that's why i decided to post a question.
For example, when i hit mysite/test.php i want that php to make a request to another .php on another server and get all the html contents of that page and echo it in test.php, is that even possible?
Let's suppose test.php is that php file which makes a request to take_me.php .
take_me.php could have just an echo or it could be a full content page.
Can i have the content of take_me.php shown in test.php?
You could use file_get_contents and echo to screen like below:
$html = file_get_contents('http://www.google.com');
if (isset($html)) {
echo $html;
}
You may have issue with images rendering correctly etc... due to paths but it will work.
http://php.net/manual/en/function.file-get-contents.php
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
My code uses this:
Method - POST
fopen then fwrite then fclose which writes in comments.
HTML Then opens comments. HTML by
<?php
require 'comments.html';
?>
Don't use require(), as it will execute any PHP code in comments.html.
Use readfile() instead, which just copies the file to the output buffer.
http://php.net/manual/en/function.readfile.php
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I use this in htm file to include another htm file
<?php include("media/android.htm"); ?>
Is this safe?
Both of them are simple htm file with text and pictures.
Yes, it's completely safe. That's how PHP works.
But, keep in mind that's a php file, not html.
use jquery to load a file
$("#div1").load("media/android.htm");
Try this
include file without php