Играх си да преписвам един код от една книга. Преди малко ми помогнаха да си оправя единият код и сичко си е 6, няма грешки. Но ето че имам следният проблем
index.php
tabs.php
И ми дава празен прозореца: http://95.169.203.168/tabs/
Някакви идеи как до го оправя.
Идеята е да се получи нещо като:
http://g.imagehost.org/0269/Untitled_4.jpg
index.php
Код:
<?php
require_once("tabs.php");
?>
<html>
<head>
<?php tabs_header(); ?>
</head>
<body>
<div style="width:600px;">
<?php tabs_start(); ?>
<?php tab("Tab One"); ?>
This is the first tab.
<?php tab("Tab Two"); ?>
This is second tab.
<?php tabs_end(); ?>
</div>
</body>
</html>
tabs.php
Код:
<?php
$tabs = array();
function tabs_header()
{
?>
<style type="text/css">
.tab {
border-bottom: 1px solid black;
text-align: center;
font-family: arial, verdana;
}
.tab-active {
border-left: 1px solid black;
border-top: 1px solid black;
border-right: 1px solid black;
text-align: center;
font-family: arial, verdana;
font-weight: bold
}
.tab-content {
padding: 5px;
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 1px solid black;
}
</style>
<?php
}
function tabs_start()
{
ob_start();
}
function endtab()
{
global $tabs;
$text = ob_get_clean();
$tabs[ count( $tabs ) -1 ][ 'text' ] = $text;
ob_start();
}
function tab( $title )
{
global $tabs;
if ( count( $tabs ) > 0 )
endtab();
$tabs []= array(
title => $title,
text => ""
);
}
function tabs_end()
{
global $tabs;
endtab();
ob_end_clean();
$index = 0;
if ($_GET['tabindex']) {
?>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
?php
$baseuri = $_SERVER['REQUEST_URI'];
$baseuri = preg_replace( "/\?.*$/", "", $baseuri );
$curindex = 0;
foreach( $tabs as $tab )
{
$class = "tab";
if ( $index == $curindex )
$class ="tab-active";
?>
<td class="<?php echo($class); ?>">
<a href="<?php echo( $baseuri."?tabindex=".$curindex ); ?>">
<?php echo( $tab['text'] ); ?>
</a>
</td>
<?php
$curindex += 1;
}
?>
</tr>
<tr><td class="tab-content" colspan"<?php echo( count( $tabs ) + 1 ); ?>">
</td></tr>
</table>
<?php
}
?>
И ми дава празен прозореца: http://95.169.203.168/tabs/
Някакви идеи как до го оправя.
Идеята е да се получи нещо като:
http://g.imagehost.org/0269/Untitled_4.jpg