I'm trying to use a PHP script to generate another php script copying from a "stub" that has replacement tags. The problem I'm facing is opening a "stub" php script and reading it line by line. I've tried multiple functions: file_get_contents(), print_r(file($file)), where $file = fopen(filename). fgets, etc. echo file_get_contents() spits out the file only starting at a certain point, so I have wondered if it is trying to run the php that is in there. The odd thing, is that if I create a new file with exactly the same content, it won't display anything!
Currently I have:
Code:
<?php
if( file_exists("Stubs/test.txt"
){
echo "This works!";
echo file_get_contents('Stubs/test.txt'
;
}
else{
echo "This doesn't work!";
}
?>
and the txt file:
Code:
<?php
require_once('util/import/ListHubImport.php'
;
class CBGoldKeyRealtyIncUTImport extends ListHubImport
{
public function __construct($date = null, $printMessages = true)
{
parent::__construct(CO_ImportScript::CBGOLDKEYREALTYINCUT, $printMessages, null, 'Coldwell Banker Gold Key Reality Inc.');
$dataConn = new DataConnection();
$dataConn->setConnectionType(DataConnection::HTTP);
$dataConn->setValidOfficeIds(array('38575'));
$this->connectionInfo = $dataConn;
$this->setSaveFilename($dataConn->getSaveDataPath() . "CBGoldKeyRealtyInc-UT_::DATE::.xml");
$this->date = $date;
$this->setSaveRecords(true);
$this->fields = $this->skippedListings = array();
//...
}
}
?>
This behavior is bizarre to me, and I'm running out of debugging options with php. Any help would be appreciated! Thanks. -Luc
PS. It shows everything from the line: $dataConn = new DataConnection(); to the end of the file.
Edit: Removed links because the discussion is off-topic
I'm trying to use a PHP script to generate another php script copying from a &quot;stub&quot; that has replacement tags. The problem I'm facing is opening a &quot;stub&quot; php script and reading it line by line. I've tried multiple functions: file_get_contents(), print_r(file($file)), where $file = fopen(filename). fgets, etc. echo file_get_contents() spits out the file only starting at a certain point, so I have wondered if it is trying to run the php that is in there. The odd thing, is that if I create a new file with exactly the same content, it won't display anything!
Currently I have:
Code:
&lt;?php
if( file_exists(&quot;Stubs/test.txt&quot;)){
echo &quot;This works!&quot;;
echo file_get_contents('Stubs/test.txt');
}
else{
echo &quot;This doesn't work!&quot;;
}
?&gt;
and the txt file:
Code:
&lt;?php
require_once('util/import/ListHubImport.php');
class CBGoldKeyRealtyIncUTImport extends ListHubImport
{
public function __construct($date = null, $printMessages = true)
{
parent::__construct(CO_ImportScript::CBGOLDKEYREALTYINCUT, $printMessages, null, 'Coldwell Banker Gold Key Reality Inc.');
// CONNECTION INFO
$dataConn = new DataConnection();
$dataConn-&gt;setConnectionType(DataConnection::HTTP);
$dataConn-&gt;setValidOfficeIds(array('38575'));
$this-&gt;connectionInfo = $dataConn;
$this-&gt;setSaveFilename($dataConn-&gt;getSaveDataPath() . &quot;CBGoldKeyRealtyInc-UT_::DATE::.xml&quot;);
$this-&gt;date = $date;
$this-&gt;setSaveRecords(true);
$this-&gt;fields = $this-&gt;skippedListings = array();
//...
}
}
?&gt;
This behavior is bizarre to me, and I'm running out of debugging options with php. Any help would be appreciated! Thanks. -Luc
PS. It shows everything from the line: $dataConn = new DataConnection(); to the end of the file.
Edit: Removed links because the discussion is off-topic