Ok, now testing it on various hosting packages/software on windows7 64 bit
machine now brings up following reactions.
On XAMPP, which tells me the following from phpinfo():
PHP Version 5.3.8
This line:
$iIndex = array_flip($this->arPlayers)[$sPlayer];
Returns/brings up the following error message:
Parse error: syntax error, unexpected '['
But, if I split it over 2 lines again, then it works fine...
Then, using verrtrigoserv:
PHP Version 5.3.10
Same error:
Parse error: syntax error, unexpected '['
But, split into 2 lines works fine there as well.
And, referring to my primarily used WAMP package/server:
PHP Version 5.4.3
It's still quite happy with either version.
For referral, the live hosting server returns the following version info:
PHP Version 5.2.17
Bit weird, and still not sure why live server just sort of hangs up instead
of telling me about an error occuring - will see if can make any changes
there somehow, or maybe it's best to leave it 'clean', and possibly just
implement a bit more of my own error handling for pages going 'live' or
something.
Alternatively, might try roll back WAMP to slightly earlier version, or
maybe at the very least, test/try out things on XAMPP instance before
putting them up on live server.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Jacob Kruger" <jacob@xxxxxxxxxxxxx>
To: <php-windows@xxxxxxxxxxxxx>
Sent: Tuesday, October 09, 2012 7:40 PM
Subject: Weird/strange issue with PHP file
Have a main, index.php file that loads another one in using the require()
function, and that second file has a class/object defined in it, with
properties, functions, etc., including the following function definition:
public function setPosition($sPlayer = "red", $iPosition = 3, $iPieceIndex =
0) {
$iIndex = array_flip($this->arPlayers)[$sPlayer];
$this->arPositions[$iIndex][$iPieceIndex] = ($iPosition -1);
}//end of setPosition function
Anyway, issue was that whole main page was just sort of locking up/making
server/browser hang/lock up for roundabout 5 minutes, until browser would
generally say something like 500 error, but with no further details, and
this is something that was operating fine on my windows7 64 bit machine,
running under WAMP, but would do this when uploaded files to linux box for
actual hosting.
Anyway, sort of assumed it was again maybe something related to some or
other strange bit of character encoding in one of the file's contents, so
firstly told notepad++ to make sure both of the files had their character
set encoding set to UTF-8 without BOM, but no go, so then stripped both
files down to literally nothing and started putting the contents back in,
piece by piece to try track down what was causing issue.
Anyway, eventually had whole of index.php back again, until I again told it
to require() the second file, and then issue started again, so there,
started off again copying/pasting the second files's contents back in bit by
bit, and got down to the last function, and that was the one copied in here
above - also literally copied and pasted it into this message.
Either way, when it turned out that that re-caused the problem, I then
firstly tried stripping it's contents down line by line, and turned out was
the first line causing the issue:
$iIndex = array_flip($this->arPlayers)[$sPlayer];
So, then tried retyping it sort of manually in case there was in fact some
or other strange character in there wasn't seeing, but, nope, so then redid
the same operation from that line into the 2 following lines:
$arFlipped = array_flip($this->arPlayers);
$iIndex = $arFlipped[$sPlayer];
Then left the rest of it as before, and all fine/working now.
Makes me think/wonder that again it must/might have something to do with a
sort of hidden character like at line end, or something, but pretty sure
made sure cleaned up whole lines, etc. before trying to retype, etc., but,
either way, really not too sure what could thus cause it to sort of hang up
as if I'd initiated an eternal recursive array iteration, or something,
unless it's something to do with PHP versions, or something, but that
doesn't really make much sense if the same functionality now works split
into 2 lines, instead of just operating in one, or something...?
Thoughts, etc.?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php