Results 1 to 2 of 2

Thread: executing php code in a string

  1. #1
    Join Date
    Mar 2005
    Posts
    83

    executing php code in a string

    ok, I've got a script that gets data from an sql database and formats it as XML, I've created an XSL sheet to format the xml data. Now, I want to be able to include PHP code within the XSL sheet.

    I'm using the following code to merge the xml code (held in a string) with the xsl file held on the server.

    Code:
    // get completed xml document
    $xml_string = $doc->dump_mem(true);
    
    // $xml and $xsl contain the XML and XSL data 
    $arguments = array('/_xml' => $xml_string); 
    
    // Allocate a new XSLT processor 
    $xh = xslt_create(); 
    
    // Process the document 
    $result = xslt_process($xh, 'arg:/_xml', $xsl_file, NULL, $arguments);  
    
    echo $result;
    xslt_free($xh);
    I've tried the eval function, but no matter what I do the final result just seems to remove any PHP code from the XSL style sheet, but doesnt seem to parse the PHP code as there is no output.

    Anyone any ideas?

  2. #2
    Join Date
    Mar 2004
    Location
    China
    Posts
    3,315
    Completly twisted. You're putting php into xml to send it to a php script which then has to try and turn the xml back into php. Why? No!

    Send php to the php script and xml to an xml client such as a web browser. You could send data in a xml streem to the php script but sending php code messed inside xml would just seem madness. As well as the security risk. You should not "execute" anything that came from the outside cause you cold be executing anything!

Similar Threads

  1. eval() if the string isn't 100% PHP code?
    By compuXP in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 18 Jul 2005, 05:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •