How to write php variable as string

I want to create one folder using php codebehind, say 'newfolder' and also want to create a file called 'index.php' which should contain the code I specified below.

<?php
$curdir = basename(dirname(__FILE__));
require_once '../template/index.php';
?>

But the problem is when I create the file index.php using php code, it writes as follows.

<?php
= basename(dirname(__FILE__));
require_once '../template/index.php';
?>

the variable gets eliminated.
Please help me solve this problem.
 
Top Bottom