Jump to content
xisto Community
Sign in to follow this  
jlhaslip

Php Version Differences? Or Not? between the trap and XAMPP???

Recommended Posts

The Trap uses php version 4.4.1 and I have downloaded and installed the XAMPP php Local Server configuration which includes php version 5.1.1 and mysql and perl etc, but this question relates to the php because that is where I am currently having difficulties.

This is the script I am having problems with locally: http://forums.xisto.com/topic/33362-script-to-build-a-list-of-links-from-filenames-and-h3-tags/

Both places have the same identical files, code and data. Both are folders in the root directory. I have used phpinfo function to confirm the server root is what it should be (public_html and htdocs) on each of them.
It isn't doing the 'explode' on the data. Is there any difference between the new line seperators? That is what I use to 'explode' the file data.

It seems that there are some pretty major differences beteen the versions.
Does anyone know where I can start to figure this out?

Share this post


Link to post
Share on other sites

There aren't that many differences between PHP4 and PHP5. Mostly, PHP5 just has new functions and features added, as well as bug fixes and enhancements to the language; to my knowledge, the fundamental usage of any existing functions has not been changed (in order to keep it backward-compatible). It would be quite dangerous for them to do so.

 

As such, I'm going to suggest that it's either a problem with the script or the data being used. About 99.9% of scripts created for PHP4 should work on PHP5. I've only very quickly looked over the script, but there does seem to be a few enhancements that could be made.

Share this post


Link to post
Share on other sites

Spectre, Thanks for the reply. I got it working, but does this make sense to you? Seems that the local version needs "\r" as the new-line seperator and Xisto needs "\n". (Windows98se) So first I found that problem and then there must have been something dropped in the download, because after re-downloading and making that small fix as noted , the logic worked? (the file opens were giving warnings and failing, so the read and close were also issuing warnings) I have no confirmation that the download was bad because (Oops!) I overwrote the first copy.And, yes, there are some enhancments to make in that script (like error checking) and tuning. As I learn some more php functions, I'll get them looked after. A spare time project and a learning / practise script.

Share this post


Link to post
Share on other sites

Windows uses \r\n (CRLF) as the new-line delimiter, and UNIX-like systems just use \n (I think Mac uses just \r, but I don't know).

As a quick fix, trying replacing:

$fp = fopen($folder_file,'r');		// open flat file for readingif (!$fp) {print 'ERROR: Unable to open file'; echo '<br />';echo $folder_file;echo '<br />';exit;}// error if no handle found for flat file$line= fread($fp,1024); // increase this length if required$f_array=explode("\n",$line);

With:

$line = @file_get_contents($folder_file);if( !$line ){    print 'ERROR: Unable to open file';   echo '<br />';   echo $folder_file;   echo '<br />';   exit();}$line = str_replace("\r\n","\n",$line);$f_array=explode("\n",$line);

Hope that's helpful.

Share this post


Link to post
Share on other sites

I've never had any trouble at all with using newlines (\n) using XAMPP, or any other method of using PHP on Windows. PHP just needs the \n even on Mac, which does use \r. You may have some sort of configuration set that requires that, but I'm not for sure. That's all that I would be able to tell you, so sorry I'm not that much help.

Share this post


Link to post
Share on other sites

Or replace it with this:

$line = @file_get_contents($folder_file);if( !$line ){   print 'ERROR: Unable to open file';   echo '<br />';   echo $folder_file;   echo '<br />';   exit();}$line = str_replace("\r\n","\n",$line);$line = str_replace("\r","\n",$line);$f_array=explode("\n",$line);
That should work for all cases: Unix, Windows and Mac.

Hamtaro: I have the Default version of XAMPP. I haven't altered the config or settings at all.

Just to clear this matterup, I might have an explanation for the variance. I have two computers. One Windows and one Mac. I may have created one data file with the Mac. Not certain, but possible.
At any rate, both versions work on the appropriate machines.
I'll have to remember to only make the data files with one or the other machines from now on.
Notice from jlhaslip:
Closing Topic.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.