Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Yamoon1983's avatar

Issue with custom helper function

After deploying website on live server, on the top of the website pages showing this:

1 like
8 replies
LaryAI's avatar
Level 58

It seems like the question is incomplete, as the description of the issue is missing. However, I can provide some general guidance on common issues with custom helper functions in PHP, especially when deploying to a live server.

  1. Check for Syntax Errors: Ensure that your helper function file does not contain any syntax errors. You can do this by running a PHP linter or using the php -l command in the terminal.

  2. Autoloading: Make sure your helper functions are being autoloaded correctly. If you're using Composer, you can add your helper file to the autoload section in composer.json:

    "autoload": {
        "files": [
            "path/to/your/helpers.php"
        ]
    }
    

    After adding it, run composer dump-autoload to regenerate the autoload files.

  3. File Inclusion: If you're not using Composer, ensure that your helper file is included in your project. You can include it manually in a bootstrap file or a service provider:

    require_once 'path/to/your/helpers.php';
    
  4. Namespace Conflicts: Check for any namespace conflicts or missing namespaces in your helper functions. If your project uses namespaces, ensure your helper functions are defined within the correct namespace or are globally accessible.

  5. Server Configuration: Ensure that the live server's PHP configuration matches your development environment. Differences in PHP versions or configurations can lead to unexpected behavior.

  6. Error Reporting: Enable error reporting on your live server temporarily to get more information about the issue:

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    

    Remember to disable error display in production after debugging.

If you can provide more details about the error message or the specific issue you're encountering, I can offer more targeted advice.

Yamoon1983's avatar

@vincent15000 this is the website brandtag.digital if you enter the website you can see the code snippet on the top of the page

1 like
Yamoon1983's avatar

I am not getting any error, but just on the head of the pages i can see the function code. The website is running without any issues, but the the code snippet on the top of each page head.

1 like
Yamoon1983's avatar

Code snippet of custom helper function is showing on the top of website pages

1 like
tykus's avatar
tykus
Best Answer
Level 104

You most likely are missing the <?php opening tag at the top of the helpers file, so the file is processed as text rather than interpreted by PHP

<?php

// your custom function(s)
2 likes

Please or to participate in this conversation.