Page 1 of 1

php include files - brand newbie

Posted: Fri Oct 30, 2009 1:16 pm
by CordLaFond
I have an application which I want to use on multiple sites.
Within a single site I use <?php include("filename.inc.php"); ?> and things work fine.

I have tried accessing the same file from a different site using <?php include("http://url.com/filename.inc.php"); ?> - no success
One source suggested removing the parentheses. I tried - no success?

I am brand new to php and don't know where to look or what to ask. I am going to start wading through some tutorials, but in the mean time, if someone could help me I would be very grateful.

Q1: How do I access an include file from a different website?
Q2: Can anyone recommend a good beginner's book or online tutorial to get familiar with basic php principles and code?

Thank You

Re: php include files - brand newbie

Posted: Fri Oct 30, 2009 1:27 pm
by akuji36
take a look at this link:

http://www.youtube.com/watch?v=SxQp7fUuMhY

thanks

Rod

Re: php include files - brand newbie

Posted: Fri Oct 30, 2009 1:31 pm
by social_experiment
Hey there,

The best way to start is to get the php manual. Use "download php manual" with Google and you should be able to download the manual.

The following example is from the php manual

Code: Select all

 
<?php 
/* This example assumes that http://www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */
 
// Won't work; file.txt wasn't handled by http://www.example.com as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';
 
// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';
 
// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';
 
$foo = 1;
$bar = 2;
include 'file.txt';  // Works.
include 'file.php';  // Works.
 
?>
 
And the text below is also from the manual ( it precedes the example ).

If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL (via HTTP or other supported wrapper - see List of Supported Protocols/Wrappers for a list of protocols) instead of a local pathname. If the target server interprets the target file as PHP code, variables may be passed to the included file using a URL request string as used with HTTP GET. This is not strictly speaking the same thing as including the file and having it inherit the parent file's variable scope; the script is actually being run on the remote server and the result is then being included into the local script.

Hope this helps