Jul 25, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

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

jlhaslip
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://www.trap17.com/forums/script-build-...nks-t33362.html

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?

Reply

Spectre
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.

Reply

jlhaslip
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 Trap17 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.

Reply

Spectre
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:

CODE
$fp = fopen($folder_file,'r');        // open flat file for reading
if (!$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:

CODE
$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.

 

 

 


Reply

Hamtaro
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.

Reply

jlhaslip
Or replace it with this:
CODE

$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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : php, version, differences, trap, xampp

  1. Mozilla Out With Firefox 3 Beta 4
    The beta 4 version of FireFox 3 is out .. (1)
  2. Sub Domain Help In Xampp
    Sub Domain Help in xampp (4)
    I am trying to work out how to get subdomains working in xampp. I have tried all of the tutorials
    on the net but I still cant work it out. Any Ideas? Thanks Rob....
  3. Compare Two Vars And Highlight The Differences
    (7)
    I need a script that compares 2 variables, and looks for a difference between them. It will then
    highlight the words that are different, as shown in the image below: So in the left cell, the
    yellow text is the text that has been removed OR replaced. In the right cell, the green text is the
    text that has replaced some text in the left cell, OR new text. This script will be used to
    compare 2 versions of a document stored in the database, to see the difference between each change
    (all revisions are stored in the database). I know that it's possible with PHP, beca....
  4. Wappychat_oldskool
    old version of my wap chat script :-) (15)
    here is a very old version of my wap chat script, its not very advanced but has privates, smileys
    etc. I will post some further versions (with owner, admin, mod status and profiles) when i have time
    to write the readme/install instructions for them. You will find instructions inside the zip. If you
    have any problems post here but i know it don't work on all servers for some reason but it does
    work on the trap server so will be cool ok /tongue.gif" style="vertical-align:middle" emoid=":P"
    border="0" alt="tongue.gif" /> ....
  5. Parsing Html As Php
    and XAMPP as the server version on Windows (7)
    On my Trap17 account here, I have an .htaccess file with the following declaration which (I think)
    forces all html files to be parsed by the PHP Parsing engine and therefore I can insert snippets of
    php scripts into html files. CODE AddType application/x-httpd-php .html .htm However, when I
    add an .htaccess file to the local directory of the version of XAMPP on my local machine, it fails.
    I have tried to add the .htaccess file to the htdocs folder and elsewhere, but it still doesn't
    work to parse html through the php parser. Any ideas on how to get these htm....
  6. Script Won't Work At Trap17 -- Version Differences?
    But works flawlessly in my machine... (12)
    Here is the code: CODE <?php $data_array = array(); $data_array2 =
    array(); $file_name = "menu_data.txt"; $handle =
    @fopen($file_name, "r"); if (!$handle)  {     echo "File
    Handle Not Available For Use"; exit;         } while (($data = fgetcsv(
    $handle, 1000, ",")) !== FALSE) {         if ( (strpos
    ($data[2],"$page=")))     {
                        $data_array[] =  t....
  7. Nexus V1.0.0 Final [public Download]
    First public download version of Nexus. (5)
    Hello all, I have finaly released my first final version of the Nexus site engine that I have been
    developing. This version is open to the public and I encourage that you try it out and give me some
    feedback. You may download the script HERE . *NOTE: I have written permmission from
    snscripts.com and from myphp.ws to use there selected software as a stand-alone in my software for
    re-distribution. Anyway you can check out the MadPHP forums at:
    http://madphp.geohosting.info/forums for more updates and information about the engine and any
    other of my scripts and p....
  8. New Version Of Phpbb!
    Available for download! (18)
    Beta and Alpha versions of phpBB, available for download! Go to http://area51.phpbb.com
    Enjoy! Tell Admin about this. /tongue.gif' border='0' style='vertical-align:middle'
    alt='tongue.gif' /> /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> ....

    1. Looking for php, version, differences, trap, xampp

Searching Video's for php, version, differences, trap, xampp
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE