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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:10:23+00:00 2026-05-23T09:10:23+00:00

I wrote a question earlier trying to get around using a controller in Kohana,

  • 0

I wrote a question earlier trying to get around using a controller in Kohana, but I gave in and rewrote the file. So now, the I have this php script inside a Kohana controller. The view that the controller is rendering is ‘requiring’ a php file so I can perform some third-party functions. I was having a major issues with it and got to debugging. The problem seems that functions inside the included file cannot access variables outside the function from within that same file. It seems that Kohana is clearing the globals somehow???

example:

//controller.php
require_once("ccfunctions.php");

//ccfunctions.php
$test = 'something';
function test(){
  global $test;
  echo $test;
}
test();
//This does not produce anything

Any thoughts on this one?

EDIT:
Actually, the above example doesn’t work even from my view file that is being rendered. Forget the included file. I realize Kohana tries to enforce the MVC model, but this is ridiculous. Why cannot I not create a function and call a global variable from within my view file?

  • 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-23T09:10:24+00:00Added an answer on May 23, 2026 at 9:10 am

    You need to specify global for variable in both cases:

    //controller.php
    require_once("ccfunctions.php");
    
    //ccfunctions.php
    global $test;
    $test = 'something';
    function test(){
      global $test;
      echo $test;
    }
    test();
    //This does not produce anything
    

    Btw, it is really weird practice and I believe there are workarounds for any case without using global

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

Sidebar

Related Questions

Ok, I wrote this question up earlier today but I decided to delete it
Partially related to an earlier question of mine , I have a system in
I am concreting a question I had earlier. I have two classes in C++
You may think this question is like this question asked on StackOverflow earlier. But
I'm trying to find a solution to a question I posted earlier about synchronizing
Okay this is a revised question from earlier today, I have included code to
My question pertains to multi-threading in Java. I'm translating an app I wrote in
So I wrote this simple console app to aid in my question asking. What
I'm writing this question with reference to this one which I wrote yesterday. After
i wrote a java app that communicates and stores data in oracle; my question

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.