| | |
Simple Question, file_get_content
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 185
Reputation:
Solved Threads: 10
I was just testing out a code and I found something rather pathetic.
This code does not produce anything.
But this code does
The php script and page.html are in the same folder, so perhaps that's the issue, but I don't see why it should make a difference if I give it the full path name or not. Am I missing something?
This code does not produce anything.
PHP Syntax (Toggle Plain Text)
<?php $source = file_get_contents("http://mysite.com/random/page.html"); echo $source; ?>
But this code does
PHP Syntax (Toggle Plain Text)
<?php $source = file_get_contents("page.html"); echo $source; ?>
The php script and page.html are in the same folder, so perhaps that's the issue, but I don't see why it should make a difference if I give it the full path name or not. Am I missing something?
0
#2 Oct 20th, 2009
You're not giving a full path, you're giving a web path. In the first example it is making a web request to fetch the file, in the second example it is directly accessing the filesystem. Make sure your path is correct or use an absolute path like
/path/to/your/webroot/page.html GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: Apr 2008
Posts: 185
Reputation:
Solved Threads: 10
0
#3 Oct 20th, 2009
Alright, so what would be the proper way to get information from a web path then?
The above code was what I was told in class yet it produced nothing when I tried to echo the teachers example page. My original code was to use a web path but since it wasn't producing any output, I decided to see what the issue was.
The above code was what I was told in class yet it produced nothing when I tried to echo the teachers example page. My original code was to use a web path but since it wasn't producing any output, I decided to see what the issue was.
Last edited by DemonGal711; Oct 20th, 2009 at 4:52 pm.
0
#4 Oct 20th, 2009
•
•
•
•
Alright, so what would be the proper way to get information from a web path then?
The above code was what I was told in class yet it produced nothing when I tried to echo the teachers example page. My original code was to use a web path but since it wasn't producing any output, I decided to see what the issue was.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: Apr 2008
Posts: 185
Reputation:
Solved Threads: 10
0
#5 Oct 20th, 2009
Alright. I think I get it. So, if I were to try and echo the contents of http://www.example.com/ , I would use this for my code right? Cause, at the moment I'm not seeing anything.
Sidenote: We have to use a variable and echo it. I know this could be a one line code.
PHP Syntax (Toggle Plain Text)
<?php $source = file_get_contents("http://www.example.com/"); echo $source; ?>
Sidenote: We have to use a variable and echo it. I know this could be a one line code.
0
#6 Oct 20th, 2009
•
•
•
•
Alright. I think I get it. So, if I were to try and echo the contents of http://www.example.com/ , I would use this for my code right? Cause, at the moment I'm not seeing anything.
PHP Syntax (Toggle Plain Text)
<?php $source = file_get_contents("http://www.example.com/"); echo $source; ?>
Sidenote: We have to use a variable and echo it. I know this could be a one line code.
ini_set('display_errors', 'On'); error_reporting(E_ALL); If you're getting an error that will show it GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
![]() |
Similar Threads
- simple question about servlet (JSP)
- simple question (Python)
- help! simple question (Python)
- HI/ I have a simple question (Domains and DNS)
- A simple question about Ram (Motherboards, CPUs and RAM)
- A Simple Question (Java)
- simple question (C++)
- Simple array question (C++)
- This has to be a simple question to answer. (Visual Basic 4 / 5 / 6)
- Simple question (Windows Servers and IIS)
Other Threads in the PHP Forum
- Previous Thread: PHP Template Tutorial Links
- Next Thread: pop up window
| Thread Tools | Search this Thread |
# 5.2.10 action address apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display dissertation domain dynamic echo echo$_get[x]changingitintovariable... email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image images include insert ip javascript joomla legislation limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop open paypal pdf persist php popup problem query radio random record recursion remote script search server sessions sms sockets source space sql syntax system table tutorial update upload url validator variable video web youtube






