php include variables without including -


can 1 tell me how "include" variable .php file without other content.

index.php

<?php $info=file('somedir/somefile.php'); $v1=trim($info[2]); $v2=trim($info[3]); $v3=trim($info[4]); ?> 

the somedir/somefile.php

<?php $variable=something; $variable2=someotherting; $variable3=thirdone!; other content there may not runned or showed. ?> 

can please me??

edit:

its dynamic page.

<html>     <?php     include_once 'config.php';     include_once 'includes/mysqlconnect.php';     $url_slash=$_server['request_uri'];     $url= rtrim($url_slash, '/');     //$url = basename($url);     $info=file('sites/'.$url.'.php');     $title=trim($info[2]);     ?>     <head>         <meta charset="utf-8">         <title>$title</title>         <link rel="stylesheet" type="text/css" href="<?php echo $domain;?>themes/reset.css">         <link rel="stylesheet" type="text/css" href="<?php echo $domain;?>themes/<?php echo $theme;?>.css">     </head>     <body class="body">         <div class="container-all">             <?php include_once 'includes/header.php';?>             <div class="container">                 <?php include_once 'includes/navigationbar.php';?>                 <?php include_once 'includes/rightsidebar.php';?>                 <div class="content"><?php                  if ($url==''){                      include_once "sites/home.php";                 }                 elseif (file_exists("sites/$url.php") && is_readable('/var/www/html/sites/'.$url.'.php')){                     include_once '/var/www/html/sites/'.$url.'.php';                  }                  else {                     include_once 'sites/404.php';                  }                   ?></div>                 <?php include_once 'includes/footer.php';?>             </div>         </div>     </body> </html> 

hope understand question now.

programming driving thoughts :)

so want question how can include part of included file , answer can achieve doing test each time main file included withing file see if file included internally or not , can more precise in way split main file block loaded due suitable variable

take workaround , hope understand mean

supposing have main file named main.php contains contents

<?php      echo 'i java programmer';      echo 'i know php well';      echo 'when jquery preferred toast !'; ?> 

now have 3 external files include file each file specific 1 of 3 programming language

so create 3 files in way :

file : java.php

<?php     $iamjavadevelopper = 1;     include_once("main.php"); ?> 

file : phpfav.php

<?php     $iamphpdevelopper = 1;     include_once("main.php"); ?> 

file : jquery.php

<?php     $iamjquerydevelopper = 1;     include_once("main.php"); ?> 

and main.php coded in way

<?php     if(isset($iamjavadevelopper))         echo 'i java programmer';     if(isset($iamphpdevelopper))         echo 'i know php well';     if(isset($iamjquerydevelopper))      echo 'when jquery preferred toast !'; ?> 

by way each 1 of our 3 external files show part of included file :)


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -