Reputation: 59
I'm using ftp_get to get content of a php file from FTP in PHP.
ob_start();
$result = ftp_get($ftp_conn, "php://output", "file.php", FTP_BINARY);
$data = ob_get_contents();
ob_end_clean();
This is file.php
<?php echo "string"; ?>
But it show php code, not content of "echo" in that php file. There any do this?
Thank so much!
Upvotes: 0
Views: 444
Reputation: 1
Replace
$result = ftp_get($ftp_conn, "php://output", "file.php", FTP_BINARY);
With this:
require 'file.php';
$data = ob_get_contents();
Upvotes: 0
Reputation: 919
Very ugly, but may succeed
ob_start();
$result = ftp_get($ftp_conn, "localcopy.php", "file.php", FTP_BINARY);
include("localcopy.php");
$data = ob_get_contents();
ob_end_clean();
Upvotes: 2