Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Funzione indefinita in php

    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($textENT_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!
    Più pratica in futuro...

  2. #2
    Sei sicuro che stai controllando il file helpers.inc.php giusto?
    "Mai discutere con un idiota. Ti trascina al suo livello e ti batte con l'esperienza." (Oscar Wilde)

  3. #3
    emm... hehe... avevi ragione tu... scusa... cioè... avevo messo la cartella del sito non nella home così php non mi pigliava il file incluso...

    grazie

    P.s.: uuuu... che vergogna.... che vergogna!!! solo io posso fare ste ca@@ate... solo io...
    Più pratica in futuro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.