Php files

Started on the old forum in May 2011 · view the original in the archive · old links redirect here

1 reply · 355 views · started 15 years ago · 1 min read

2 participants
Youngestdj Newbie · 1 posts #1

I need a little help with creating files after creating a directory.

<?php $name = $_GET['name']; mkdir("$name"); /*I want two files to be created immediately after the dir is created e.g index.php & count.txt with some values in them in the directory "$name". How do I do that?*/ ?>

Hazard ma lyf 4 'im

kei_ki7 Senior · 431 posts #2
<?php
makePage(
function makePage($pageContent,$pageName){
	$fp = fopen("$pageName", "w");
	fwrite($fp, $pageContent); 
	fclose($fp);
	return true;
}

$pageContent = '<?php
echo "kei_ki7";
?>';
makePage($pageContent, 'index.php');
?>

Didn't test yet. Hope it works

Did I help you? You can help me too Your donations will help me finance my studies.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close