Kizel171 Posted April 24, 2006 Share Posted April 24, 2006 So I'm writing an administration script for a database application I wrote and I want to create a PHP file that will render an index.php file that contains $_SESSION variables written by the setup program. The problem is when I go to create the $filedata varaible for fwrite() there is no way to put <?php into a string without having php start parsing the rest of the string.I'm trying to do this...$filedata = "<html xmlns=\"http://www.w3.org/1999/xhtml\"> \n<head> \n<meta http-equiv=\"Content-Type\" content=\"text/html\; charset=iso-8859-1\" /> \n<title>CACP</title> \n</head> \n\n<body> \n<?php \n\$_SESSION[rem_dbhost] = $dbhost; \n\$_SESSION[rem_dbname] = $dbname; \n \$_SESSION[rem_dbuser] = $dbuser; \n\$_SESSION[rem_dbpassword] = $dbpassword; \n\nheader(\"Location: .\"\$_SERVER['DOCUMENT_ROOT'].\"/cedric/index.php\"); \nexit; \n?> \n</body> \n</html> \n ";but if you print that variable back to the screen it returns a nice white nothing eventhough it is set when tested with isset().I played around with commenting out different parts of the variable assignment to isolate the problem and its the <?php tag. As soon as that's gone then the string goes into the variable just fine.Thanks in advance for suggestions. Quote Link to comment https://forums.phpfreaks.com/topic/8229-creating-a-php-file-with-php/ Share on other sites More sharing options...
kenrbnsn Posted April 24, 2006 Share Posted April 24, 2006 Take a look at the function [a href=\"http://www.php.net/htmlentities\" target=\"_blank\"]htmlentities()[/a]. One of the things it does is change "<" and ">" into "<" and ">", which will make the browsers leave the string as is. You can also surround the string with the '<pre>' and '</pre>' tags.Ken Quote Link to comment https://forums.phpfreaks.com/topic/8229-creating-a-php-file-with-php/#findComment-29989 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.