-1

I open php file by fopen() and call it by fread() and fclose(), but it's not executed and it's just read as when I open it by Inspect Element.

I tried it by htmlspecialchars() but it just printed as String.

I need some suggestions, please, in order to I can execute another php file from php. Thanks.

Garry14
  • 41
  • 9
  • 2
    [`fopen()`](http://www.php.net/manual/en/function.fopen.php) *opens a file descriptor, which functions as a stream to read or write the file* (see http://stackoverflow.com/a/24008078/689579). If you want to execute the php file, you need to use [`include()`](http://www.php.net/manual/en/function.include.php) or [`require()`](http://www.php.net/manual/en/function.require.php) – Sean Jan 23 '17 at 00:49
  • Yes, I use include(), thanks. – Garry14 Jan 24 '17 at 01:07

2 Answers2

0

Friend I think you can use file_get_contents(). IT can help you execute another php file from php. http://php.net/manual/en/function.file-get-contents.php

gzchen
  • 62
  • 5
  • I had found the solution, I use import(), then I declare a function that I put the import() into it. After that I make a variable that calls the function.. My purpose is, I want to call n execute my "another" php file and put it in a variable.. Thanks. – Garry14 Jan 24 '17 at 01:14
  • @Garry14 yes include and require can help you do it. – gzchen Jan 24 '17 at 01:34
  • Sorry, yes.. I mean include() :D – Garry14 Jan 24 '17 at 02:01
0

I had found the solution. My purpose is, I want to call n execute my "another" php file and put it into a variable. I use inclde(), then I declare a function that I put the include() into it. After that I make a variable that calls the function..

I use this solution. require/include into variable

Thanks, btw ;)

Community
  • 1
  • 1
Garry14
  • 41
  • 9