Answer the question
In order to leave comments, you need to log in
Code inside. How to put include into a variable?
<? $siteMenu="<?
include $_SERVER['DOCUMENT_ROOT'].'/core/modules/menu.php';
?>" ?>
Does not work. Why? how to shove ikludu into a variable?
Answer the question
In order to leave comments, you need to log in
Option 1.
the contents of the menu.php file should be like this
<?php
return array(
"пункт меню 1",
"пункт меню 2",
"пункт меню 3",
);
<?php
function getMenu()
{
ob_start();
include $_SERVER['DOCUMENT_ROOT'].'/core/modules/menu.php';
return ob_get_clean();
}
$siteMenu = getMenu();
<ul><li>пункт меню 1</li><li>пункт меню 2</li><li>пункт меню 3</li></ul>
//Файл отдельный one.php в нём:
$siteCore = "<link rel="stylesheet" type="text/css" href="/core/css/style.css">
<link rel="stylesheet" type="text/css" href="/core/css/adaptive.css">
<link rel="stylesheet" type="text/css" href="/core/font/styles.css">
<link rel="icon" type="image/gif" href="/core/img/favicon.gif">"
//Теперь код основного сайта
include 'one.php';
echo "$siteCore";
Try it:
$site_menu = function() {
include $_SERVER['DOCUMENT_ROOT'] . '/core/modules/menu.php';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question