Ho un file jokes.html.php di questo tipo:
Codice PHP:
<?php include_once $_SERVER['DOCUMENT_ROOT'] .
'/includes/helpers.inc.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Manage Jokes: Search Results</title>
</head>
<body>
<h1>Search Results</h1>
<?php if (isset($jokes)): ?>
<table>
<tr><th>Joke Text</th><th>Options</th></tr>
<?php foreach ($jokes as $joke): ?>
<tr valign="top">
<td><?php markdownout($joke['text']); ?></td>
<td>
<form action="?" method="post">
<div>
<input type="hidden" name="id" value="<?php
htmlout($joke['id']); ?>">
<input type="submit" name="action" value="Edit">
<input type="submit" name="action" value="Delete">
</div>
</form>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<p><a href="?">New search</a></p>
<p><a href="..">Return to JMS home</a></p>
</body>
</html>
che come potete vedere richiama il file helpers.inc.php.
Dentro il file helpers.inc.php c'è questo codice:
Codice PHP:
<?php
function html($text)
{
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}
function htmlout($text)
{
echo html($text);
}
function markdown2html($text)
{
$text = html($text);
// strong emphasis
$text = preg_replace('/__(.+?)__/s', '<strong>$1</strong>', $text);
$text = preg_replace('/\*\*(.+?)\*\*/s', '<strong>$1</strong>', $text);
// emphasis
$text = preg_replace('/_([^_]+)_/', '<em>$1</em>', $text);
$text = preg_replace('/\*([^\*]+)\*/', '<em>$1</em>', $text);
// Convert Windows (\r\n) to Unix (\n)
$text = str_replace("\r\n", "\n", $text);
// Convert Macintosh (\r) to Unix (\n)
$text = str_replace("\r", "\n", $text);
// Paragraphs
$text = '<p>' . str_replace("\n\n", '</p><p>', $text) . '</p>';
// Line breaks
$text = str_replace("\n", '<br>', $text);
// [linked text](link URL)
$text = preg_replace(
'/\[([^\]]+)]\(([-a-z0-9._~:\/?#@!$&\'()*+,;=%]+)\)/i',
'<a href="$2">$1</a>', $text);
return $text;
}
function markdownout($text)
{
echo markdown2html($text);
}
quando accedo a jokes.html.php ottengo questo errore:
Fatal error: Call to undefined function markdownout() in C:\xampp\htdocs\LIBRO\chapter8\admin\jokes\jokes.h tml.php on line 16
Se sostituisco a
Codice PHP:
<td><?php markdownout($joke['text']); ?></td>
la stringa
Codice PHP:
<td><?php htmlout($joke['text']); ?></td>
il codice funziona alla perfezzione quindi deduco che la funzione markdownout() ha realmente qualcosa che non va ma cosa!?!?!





... non è possibile deve andare, è tutto giusto!