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

  • SEARCH
  • Home
  • 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 7524903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:11:13+00:00 2026-05-30T03:11:13+00:00

In PHP 5.3.6 I have a class with a method like this: public function

  • 0

In PHP 5.3.6 I have a class with a method like this:

public function chunkText()
{
  if(!function_exists('unloadChunkText')) {
     function unloadChunkText() {
        . . .
     }
  }
  . . .
}

Where unloadChunkText is a helper method for chunkText. The problem is that whenever I call $obj->chunkText() I am given this error:

Cannot redeclare diagnostic\question\unloadChunkText() (previously
declared in
file.php:34)
in file.php
on line 34

Why isn’t function_exists telling me that this function already exists?

  • 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-05-30T03:11:15+00:00Added an answer on May 30, 2026 at 3:11 am

    You are checking for the global function unloadChunkText, instead of the namespace-specific function diagnostic\question\unloadChunkText. But I suspect your approach here is flawed.

    If you have a helper function for your method chunkText(), define it in one of two ways:

    As a closure:

    public function chunkText()
    {
      $unloadChunkText = function () {
        // . . .
      };
      // . . .
      // Call it like $unloadChunkText()
    }
    

    As a private method of the object:

    private function unloadChunkText ()
    {
      // . . .
    }
    
    public function chunkText()
    {
      // . . .
      // Call it like $this->unloadChunkText()
    }
    

    Defining it as a private method probably makes more sense, so you don’t waste time redefining it every time you call chunkText().

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

Sidebar

Related Questions

I have Login.php form like this: class Form_Login extends Zend_Form { public function init()
I have a class that looks like this: utils/Result.php <?php class Result { public
I have joined models like this: // /foo/lib/model/doctrine/PurchasedItemTable.class.php public function retrievePurchased(Doctrine_Query $q) { $rootAlias
I have a class method that deals with dates: public function setAvailability(DateTime $start, DateTime
I have this method in my db class public function query($queryString) { if (!$this->_connected)
I have a class like this: class A { public $var = ; function
I currently have my PHP class variables set up like this: class someThing {
If I have a PHP class such as this one: class A { public
Suppose I have simple class like: class MyClass { private $_prop; public function getProp()
I have a model with two functions, like this: <?php class FotoModel extends CI_Model

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.