Forum Moderators: coopster

Message Too Old, No Replies

Persistence of resources in PHP

php resources persistence

         

caraie

6:23 am on Oct 25, 2009 (gmt 0)

10+ Year Member



Hi!, sorry my bad english isn't my first language.
I have a problem from several days ago, and it's driving me crazy. I have a resource (an ftp resource) and I want to use this resource in several pages; for example in page A I connect the ftp ($resource=ftp_connect()), in the page B i have to delete files (ftp_delete ($resource,...)). I don't know how to "move" this resources between pages. I tried using a session, but the resources are not serializable, any tip or idea?

Thanks a lot!

g1smd

8:03 am on Oct 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are these files in the same server, or a different server?

TheMadScientist

11:26 am on Oct 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Move the resource you would like to use in multiple files to a single file, and then use:

include $_SERVER['DOCUMENT_ROOT'].'the/path_to_the/file.php';
(If they are on the same server.)

include 'http://www.example.com/the/path_to_the/file.php';
(If they are on different servers.)

You can switch to require, include_once, or require_once depending on your exact needs.