saifai: (Just a flesh wound (_omgicons))
[personal profile] saifai
I'm trying to convert a function from file_get_contents to GetContents.

There was a suggested code fix listed, but I'm not sure how to convert the code to work with the script I'm using.  I've got the basics down, but there's additional functions listed there and I don't know how to place them.

Anyone out there that can help?

*hears crickets*

Date: 2006-08-04 03:41 am (UTC)
From: [identity profile] chicken-cem.livejournal.com
Yes -- file_get_contents is a standard PHP function. I don't see "GetContents" listed anywhere on PHP.net. The very fact that it is capitalized suggests it is part of some third-party system, templating engine, etc. because all standard PHP functions (as documented at php.net) are lowercase. Can you give more information/context?

Date: 2006-08-04 03:54 am (UTC)
ext_74119: (Default)
From: [identity profile] saifai.livejournal.com
I'm getting an error with a header file (which I'm told is happening because of a PHP compatibility issue):
Fatal error: Call to undefined function: file_get_contents()

That's referring to a specific line in the code:
if(file_exists(_BASEDIR."messages/tinymce.txt")) $tinymcesettings = file_get_contents(_BASEDIR."messages/tinymce.txt");

Someone suggested for different software to replace the function:
try adding the following function to the class library and changing the call to file_get_contents to call
GetContents instead.

function getContents( $filename )
{
if ( function_exists( 'file_get_contents' ) )
{
return file_get_contents( $filename );
}
else
{
$fp = fopen( $filename, 'r' );
if ( !$fp )
{
eZDebug::writeError( 'Could not read contents of ' . $filename, 'eZFile::getContents()' );
return false;
}

return fread( $fp, filesize( $filename ) );
}
}


Of course, I have no clue about any of that. I've seen other suggestions, like using something called "implode," and even some complicated library something-er-other replacements.

I'm befuddled...

Date: 2006-08-04 02:18 pm (UTC)
From: [identity profile] chicken-cem.livejournal.com
Oh, OK, I thought the new function (GetContents) was user-defined. Got it. It's because file_get_contents only works if you have PHP version 4.3.0 or above. You clearly are running an older version below that.

So what happened when you added the replacement function? It looks OK (although EZDebug and EZFile also obviously need to be defined somewhere).

Date: 2006-08-04 02:37 pm (UTC)
From: [identity profile] chicken-cem.livejournal.com
P.S., It's really tough to help without context. If you want to send me the whole script, I can fix it for you very quickly.

chickenofeathers@yahoo.com

Profile

saifai: (Default)
saifai

April 2017

S M T W T F S
      1
2345678
9101112 131415
16171819202122
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 22nd, 2025 09:34 pm
Powered by Dreamwidth Studios