Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-11-2009, 12:26 AM   PM User | #1
millsi80
New Coder

 
Join Date: Jun 2008
Posts: 93
Thanks: 12
Thanked 1 Time in 1 Post
millsi80 is an unknown quantity at this point
Question about PHP Includes

Hi,

I was wondering if PHP includes only work if the file is on the same server or whether it can grab and 'include' files from other servers.

Thanks
millsi80 is offline   Reply With Quote
Old 09-11-2009, 01:12 AM   PM User | #2
Zangeel
Regular Coder

 
Zangeel's Avatar
 
Join Date: Oct 2007
Location: public_html/
Posts: 638
Thanks: 17
Thanked 79 Times in 79 Posts
Zangeel will become famous soon enough
Only if your server configuration allows URL File Access. But you can't access it's Server Side codes, just it's HTML and client side stuff, like file_get_contents().
__________________
PHP Code:
$aString is_string((string)array()) ? true false// true :D 
[/CENTER]
Zangeel is offline   Reply With Quote
Users who have thanked Zangeel for this post:
millsi80 (09-11-2009)
Old 09-11-2009, 02:18 AM   PM User | #3
millsi80
New Coder

 
Join Date: Jun 2008
Posts: 93
Thanks: 12
Thanked 1 Time in 1 Post
millsi80 is an unknown quantity at this point
Ah, alright thanks
millsi80 is offline   Reply With Quote
Old 09-11-2009, 07:10 PM   PM User | #4
Coyote6
Regular Coder

 
Join Date: May 2009
Location: Moore, OK
Posts: 277
Thanks: 10
Thanked 41 Times in 41 Posts
Coyote6 is an unknown quantity at this point
You can however, if you have control over both servers (and highly recommend doing this only if you do), you can use php to write out php onto the html page. Then access it using an include, but you must also make sure you have url_include turned on in php. It is shutoff normally by default because it can lead to an attack on your website if you do not control the site being accessed.

Ex. Script 1 - File name is 'script_1.php' at http://www.server_a.com
PHP Code:
<?php
  
echo '<?php echo "hello world"; ?>';
?>
Ex. Script 2 - File name is 'script_2.php' at http://www.server_b.com
PHP Code:
<?php
  
include 'http://www.server_a.com/script_1.php';
?>
Results would be:
Code:
hello world
What happens when you do not control server_a is the person who does control it now controls yours as well which is why it is not recommended that you do this. Truthfully they could erase your entire server if they are good enough.
Coyote6 is offline   Reply With Quote
Reply

Bookmarks

Tags
include, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:24 PM.


Advertisement
Log in to turn off these ads.