|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
create and write php file
hi guys,
I am wondering is it possible to create a php file and write the php file we created by using php code ?? Is there any function or code that let us do this ?? I seen some people perform such tasks in their web application but i dunno how to do it .. please advise. |
|
#2
|
|||
|
|||
|
You want to use PHP to create a file, in this case a .php file which includes PHP-code?
Do I understand you correctly? Ofcourse you can do that. You can use PHP's file functions to create almost any kind of file with whatever content suits you. You can easily create a file with the .php extension and write PHP code to it. <?php $filename = 'helloworld.php'; $content = ' <?php echo "Hello world!"; ?> '; if (!$handle = fopen($filename, 'w')) { print "Cannot open file ($filename)"; exit; } if (!fwrite($handle, $content)) { print "Cannot write to file ($filename)"; exit; } fclose($handle); ?> |
|
#3
|
||||
|
||||
|
Um, but I'd be very careful about doing that. For example, if you're hoping to allow users to add code to the site, you'll need to keep them from being able to add things like the following:
PHP Code:
|
|
#4
|
|||
|
|||
|
dhouston: You are right.
When allowing things like these, you must take proper security precautions. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > create and write php file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|