How to write php variable as string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ganesh_dabhade
Forum Newbie
Posts: 19
Joined: Sun Feb 06, 2011 12:42 am
Contact:

How to write php variable as string

Post by ganesh_dabhade »

I want to write the following code in index.php file

Code: Select all

<?php 
$curdir = basename(dirname(__FILE__));
require_once '../template/index.php';
?>
But the problem is when I create the file index.php, it writes as follows.

Code: Select all

<?php 
 = basename(dirname(__FILE__));
require_once '../template/index.php';
?>
the variable is eliminated.
Please help me solve this problem.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: How to write php variable as string

Post by social_experiment »

ganesh_dabhade wrote:...when I create the file index.php...
Do you refer to 'when i type it in my editor'?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
ganesh_dabhade
Forum Newbie
Posts: 19
Joined: Sun Feb 06, 2011 12:42 am
Contact:

Re: How to write php variable as string

Post by ganesh_dabhade »

I want to create one folder say 'newfolder' and also want to create a file called 'index.php' which should contain the code I specified in my above problem.
Post Reply