amin
amin

Reputation: 31

how to use include straight in define in php

I want to use include straight in define in php

for e.g.

<?php define('panel' , 'include "../panel/admin.php";'); //in a saperate php page ?>

and include this file

Now I want use

<?php panel ?> //in another page

Upvotes: 0

Views: 102

Answers (2)

Ravi Hirani
Ravi Hirani

Reputation: 6539

mohade's answer is correct.

However you can do the same with your existing code by below way.

 define('panel' , 'include "/panel/admin.php";'); 

 eval(panel); // eval — Evaluate a string as PHP code

Hope it will help you :)

Upvotes: 0

Mo Shal
Mo Shal

Reputation: 1637

you cant use include() in define

you must do this

<?php define("panel" , "../panel/admin.php"); ?>

and then include it

<?php 

include(panel);

 ?>

Upvotes: 8

Related Questions