Autor | Zpráva | ||
---|---|---|---|
Manny Profil |
#1 · Zasláno: 3. 9. 2015, 12:59:52
Už jsem v koncích. Následující funkcí vypisuji obsah do stránky v mém CMS.
function content($strana) { global $spojeni; if($strana["autotitle"] == 1) //je zapnutý automatcký titulek? $output = '<h1>'.$strana["title"].'</h1>'; if($strana["type"] == 6) $output .= '<h1>'.$strana["title"].'</h1>'; $output .= preg_replace_callback("/(\[mod\]){1}.+(\[\/mod\]){1}/","najdimodul",$strana["content"]); if($strana["type"] == 2 && $strana["pull_down_intersec"] == 1) $output .= require "require/pull_down_intersec.php"; if($strana["type"] == 3) $output .= require "require/forum.php"; if($strana["type"] == 4) $output .= require "require/gallery_show.php"; if($strana["type"] == 5) $output .= require "require/article.php"; return $output; } require se na konci výstupu objeví 1.
Samozřejmě jsem myslel, že to je něco zapomenutého, ale není. Je to u všech souborů, které se vkládají přes require .
|
||
tiso Profil |
#2 · Zasláno: 3. 9. 2015, 13:08:20
Pri tomto spôsobe musíš v include súboroch použiť return: http://php.net/manual/en/function.include.php#example-157
|
||
juriad Profil |
#3 · Zasláno: 3. 9. 2015, 13:10:53
Manny:
„require is identical to include except upon failure“ php.net/function.require „include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1.“ php.net/manual/en/function.include.php To je důvod, proč se ti do $output dostane 1. Require (a include) jinak vypíší svůj obsah okamžitě na výstup (pokud není zapnutý output buffer). |
||
Manny Profil |
#4 · Zasláno: 3. 9. 2015, 13:35:16
tiso, juriad:
Díky pánové. Pomohlo to. |
||
Časová prodleva: 8 let
|
0