General discussion
Php Script that generate another

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"smile){
echo "This works!";
echo file_get_contents('Stubs/test.txt'smile;
}
else{
echo "This doesn't work!";
}
?>

and the txt file:
Code:
<?php

require_once('util/import/ListHubImport.php'smile;

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->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&#039;m trying to use a PHP script to generate another php script copying from a &amp;quot;stub&amp;quot; that has replacement tags. The problem I&#039;m facing is opening a &amp;quot;stub&amp;quot; php script and reading it line by line. I&#039;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&#039;t display anything! Currently I have: Code: &amp;lt;?php if( file_exists(&amp;quot;Stubs/test.txt&amp;quot;)){ echo &amp;quot;This works!&amp;quot;; echo file_get_contents(&#039;Stubs/test.txt&#039;); } else{ echo &amp;quot;This doesn&#039;t work!&amp;quot;; } ?&amp;gt; and the txt file: Code: &amp;lt;?php require_once(&#039;util/import/ListHubImport.php&#039;); class CBGoldKeyRealtyIncUTImport extends ListHubImport { public function __construct($date = null, $printMessages = true) { parent::__construct(CO_ImportScript::CBGOLDKEYREALTYINCUT, $printMessages, null, &#039;Coldwell Banker Gold Key Reality Inc.&#039;); // CONNECTION INFO $dataConn = new DataConnection(); $dataConn-&amp;gt;setConnectionType(DataConnection::HTTP); $dataConn-&amp;gt;setValidOfficeIds(array(&#039;38575&#039;)); $this-&amp;gt;connectionInfo = $dataConn; $this-&amp;gt;setSaveFilename($dataConn-&amp;gt;getSaveDataPath() . &amp;quot;CBGoldKeyRealtyInc-UT_::DATE::.xml&amp;quot;); $this-&amp;gt;date = $date; $this-&amp;gt;setSaveRecords(true); $this-&amp;gt;fields = $this-&amp;gt;skippedListings = array(); //... } } ?&amp;gt; This behavior is bizarre to me, and I&#039;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
edited Dec 1 '14 at 3:34 am
93
0
1
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft