Jimity Posted May 14, 2016 Share Posted May 14, 2016 Hi All, I'm using some of my own PHP coding in conjunction with a WYSIWYG website program (to save time) which uses inbuilt controls to allow me create a solution. Everything compiles fine and works, however I find I need to manually edit some of the compiled / created files with custom information / settings etc in order to make things work better (this is due to the rigid structure of some of the pre-built controls I am using in this program). Anyway, I'm looking to create a PHP script that will go into the files that need manual editing and make the changes for me. I'm doing well so far, reading in the required file, and using the string replace command etc as a prototype, however I need to change a php variable string in one of my files to read as a session variable string. E.G I need the string "$Variable" in the file to actually say "$_SESSION['sessionvariable']" instead. Can anyone help me with a piece of code that may be able to do this ? Quote Link to comment https://forums.phpfreaks.com/topic/301187-how-to-string-replace-a-variable-name-in-a-file-with-a-session-variable-name/ Share on other sites More sharing options...
requinix Posted May 14, 2016 Share Posted May 14, 2016 If that $Variable thing was your actual problem then I would say Rather than change the generated code, can you simply have something do $Variable = $_SESSION['sessionvariable']; before executing the file? If that's not your actual problem, what is? Quote Link to comment https://forums.phpfreaks.com/topic/301187-how-to-string-replace-a-variable-name-in-a-file-with-a-session-variable-name/#findComment-1532999 Share on other sites More sharing options...
Jacques1 Posted May 14, 2016 Share Posted May 14, 2016 Editors also have this cool new feature called search-and-replace. If yours doesn't, get a proper editor like Notepad++ or an IDE like Netbeans or Eclipse. Quote Link to comment https://forums.phpfreaks.com/topic/301187-how-to-string-replace-a-variable-name-in-a-file-with-a-session-variable-name/#findComment-1533000 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.