0

So, I want to have my class include another file which in turn executes the return statement...

class layout {
    public static function make($file) {
        include $file;
    }
}

I have a mylayout.layout.php

<?php 
return true;

and then I do

echo layout::make('mylayout.layout.php');

Result is null

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
Petter Thowsen
  • 1,697
  • 1
  • 19
  • 24

2 Answers2

4

include is not equal to copy and pasting of code. You do not return anything from the layout::make method, so nothing (null) is returned. You have to write return in the code in your class to return something from the method.

deceze
  • 510,633
  • 85
  • 743
  • 889
0

I got a reply on IRC. Problem is, the return from the external file goes to the include function. So I have to return the value of (include 'mylayout.layout.php');

I also found this post by reformatting my question for google: Return from include file

Community
  • 1
  • 1
Petter Thowsen
  • 1,697
  • 1
  • 19
  • 24