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 735371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:28:53+00:00 2026-05-14T07:28:53+00:00

I have a function that I use on index.php page and I would like

  • 0

I have a function that I use on index.php page and I would like to call it from other php page (other.php). How to make this function available without redeclaration? I think it’s achievable using sessions, but I am not sure how to do it exactly.

Th problem is that it works in index.php, because it uses some API declaration, but it doesn’t on other.php. I am not sure how to setup the API on other.php page, so I will need some sort of session pass rather than seperate file with functions. Any ideas?

EDIT: Maybe it’s confusing, so I will try to clarify it. I have a page let’s say index.php with a function: get_loggedin_user(); . It prints the user’s name. It works in index.php because it is a part of a CMS system with an API and uses this API. The problem is that I would like to use this function on (or in worst case pass the user’s name) to other page (other.php) which is accessible by the link form index.php. Now I would like to print user’s name on other.php. Is this achievable? I know I can pass the name using sessions and I would like to know how to do this, or if it is possible, how to access this function. Hope it’s clear now.

  • 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-14T07:28:54+00:00Added an answer on May 14, 2026 at 7:28 am

    You’ld be better of having your functions declared in one php file and include it in all php files where you need it.

    <?php
    
    // require_once will prevent a file being included multiple times
    // and so prevents functions from being redeclared again (which would cause errors)
    require_once 'yourfilewithfunctions.php';
    
    $result = call_your_function( $with, $parameters );
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.