Solved

How to change two parameters in a PHP file?!

Posted on 2008-06-12
4
235 Views
Last Modified: 2008-06-19
Hello group,

I'm writing a small web application which allows a user to upload a game (Flash base). Let's say user uploads a file called game.swf
On the fly, the code creates a game.php associated to the game. So now we have:
1) game.swf
2) game.php files on server.

The generated PHP file is a page and it also has the <embed> tag injected in it. Of course, it has two parameters as WIDTH and HEIGHT which specify the dimension of the game. So far, I don't have any issue.

The problem is that if the game owner decides to apply changes (such as name, description and etc) it works fine but I don't know how to change the width and height parameters which already are hard coded in the generated PHP file.

Is there any function that let me to change two or more values in an existing PHP/HTML file?

Any suggestions or advice will be appreciated.

Regards.
0
Comment
Question by:akohan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Assisted Solution

by:afzz
afzz earned 100 total points
ID: 21772683
If the file is not too big use the file() function to read the file into an array, loop through the array to find what you want to change while saving the rest into another variable when you come acroos the values to change, save the changed values into the new variable and finally write it back to the file

0
 

Author Comment

by:akohan
ID: 21772751

Yes, it is small. I will give a try.

Thanks!
0
 
LVL 5

Accepted Solution

by:
pbeirne earned 400 total points
ID: 21772772
You could keep the width and height parameters in an include file or stored in a mySQL database rather than hard coding them in your page.  Then your application's update routine could update or replace the include file or mySQL and your PHP page wouldn't have to be modified.
0
 

Author Comment

by:akohan
ID: 21825693

Both methods were fine but the latter gave me more flexiblity.

Thanks to all.
Regards.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question