Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8782589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:36:06+00:00 2026-06-13T20:36:06+00:00

Within a function on my parent file, I am calling a function from an

  • 0

Within a function on my parent file, I am calling a function from an external php file. Here is my (simplified) code:

Parent file:

include "HelperFiles/htmlify.php";

function funcName(){
    $description = "some sample text"; 
    $description = htmlify($description, "code");

    echo $description;
};
funcName();

htmlify.php file with called function:

$text = "";

function htmlify($text, $format){

    if (is_array($_POST)) {
          $html = ($_POST['text']);
        } else {
          $html = $text;
        };    

        $html = str_replace("‘", "'", $html); //Stripping out stubborn MSWord curly quotes
        $html = str_replace("’", "'", $html);
        $html = str_replace("”", '"', $html);
        $html = str_replace("“", '"', $html);
        $html = str_replace("–", "-", $html);
        $html = str_replace("…", "...", $html);



      if ($format == "code"){

        $html = str_replace(chr(149), "•",$html);
        $html = str_replace(chr(150), "—",$html);
        $html = str_replace(chr(151), "—",$html);
        $html = str_replace(chr(153), "™",$html);
        $html = str_replace(chr(169), "©",$html);
        $html = str_replace(chr(174), "®",$html);


       $trans = get_html_translation_table(HTML_ENTITIES);
       $html = strtr($html, $trans);

       $html = nl2br($html);
       $html = str_replace("<br />", "<br>",$html);

       $html = preg_replace ( "/(\s*<br>)/", "\n<br>", $html );  // seperate lines for each <br>
       //$text = str_replace ( "&amp;#", "&#", $text );
       //return htmlspecialchars(stripslashes($text), ENT_QUOTES, "UTF-8");

        return htmlspecialchars($html, ENT_QUOTES, "UTF-8");
      }
      else if ($format == "clean"){
        return $html;
      }

};

I’m getting the following error:

Notice: Undefined index: text in C:_Localhost_Tools\HelperFiles\htmlify.php on line 25

I’ve tried declaring the $text variable inside and outside of scope in multiple places but can not seem to get around this error (warning). Any help would be greatly appreciated! Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:36:07+00:00Added an answer on June 13, 2026 at 8:36 pm

    replace

    if (is_array($_POST)) {
    

    with

    if (isset($_POST['text'])) {
    

    and you should not get the warning anymore.

    However I would recommend to remove this alltogether. The function parameter should always be used – everything else is confusing.

    And you can also remove the first line in htmlify.php – that does basically nothing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to use include within a function? i have two file inc.php
I have created a function within my themes functions.php file in order to persist
This code takes data from a php file which is doing a json_encode, which
I wanted to call Test1() Method Within WaitAndCallFunc() Function. Code: typedef void (*func)(); void
I have to allocate a struct from within another function, obviously using pointers. I've
I'm having an issue calling a javascript function within a Google Maps InfoWindow. The
Is it possible to include (or, for my uses, run ) another PHP file
Is it possible to call function within the same function without specifying the function
I am essentially trying to set a function's prototype within the function itself. The
I have a background worker which calls a function within a separate class. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.