« first day (1840 days earlier)      last day (3114 days later) » 

12:09 AM
trying to add wordnet dictionary to website. I have the files but i have no idea how to install. and cant find any decent instructions
maybe wrong room?
ahhhhh
!
 
 
1 hour later…
@Mark "where you accidentally return a value from a method that was actually supposed to set a value?" No, I'm pretty sure I'm able to tell setters and getters apart.
"void return type is more about documentation." - which is why I would strongly prefer null. It correctly describes what the function is doing (returning only a null value) rather than trying to describing something a bit misleading.
3
I refer you to the people who are already suggesting 'fixing' the behaviour of the PHP engine to match the 'void' return type.
 
hmm
I'm currently wondering how the PHP-FIG will handle type hints and existing interfaces
wlll they add them where they don't break BC?
(i.e. for parameters)
 
Begin 15 months discussion here.
 
it's a rather straightforward question
maybe they could make a derived interface with type hints or something
$ php -r 'interface A { public function foo(array $a); } class B implements A { public function foo($a) {} }'
PHP Fatal error:  Declaration of B::foo($a) must be compatible with A::foo(array $a) in Command line code on line 1

Fatal error: Declaration of B::foo($a) must be compatible with A::foo(array $a) in Command line code on line 1
$ php -r 'interface A { public function foo($a); } class B implements A { public function foo(array $a) {} }'
PHP Fatal error:  Declaration of B::foo(array $a) must be compatible with A::foo($a) in Command line code on line 1
Oh.
So much for contravariance
 
yes.
We are currently mitigating an attack. Standby for updates.
 
1:59 AM
pinging @LeviMorrison to see how annoyed or not this makes him
oh my god what
return types and parameter types are inconsistent
parameter types are invariant, return types are covariant
o.O
$ php -r 'interface A { public function foo($a): array; } class B implements A { public function foo($a) {} }'
PHP Fatal error:  Declaration of B::foo($a) must be compatible with A::foo($a): array in Command line code on line 1

Fatal error: Declaration of B::foo($a) must be compatible with A::foo($a): array in Command line code on line 1
$ php -r 'interface A { public function foo($a); } class B implements A { public function foo($a): array {} }'
@LeviMorrison explain this?
 
... is there any usage for anonymous exceptions?
 
Abe
return types don't support variance at all currently @Andrea
 
@Abe look at the example
@marcio evil
 
Abe
@Andrea hm?
 
2:07 AM
interface A { public function foo($a); } class B implements A { public function foo($a): array {} }
this is accepted
that's a very limited form of covariance
 
Abe
it must be a mistake :B
afaik variance wasn't intended at all
@marcio looks like something i would use #imtheworst
 
Yea, perhaps anonymous exceptions should have been prevented. I couldn't think about any reason to have "throw new class("evil") extends SomeException {};", but maybe this needs more thinking.
 
2:27 AM
@Andrea The second example looks suspect.
You are saying you are getting a fatal or that you aren't but should?
 
Abe
@marcio i wouldn't prevent them but it's unlikely they have use cases. it's already hard finding use cases for regular anonymous classes objects
 
2:43 AM
@LeviMorrison I'm not getting an error
yet I would for the opposite case with parameters
 
This is a limited form of covariance.
 
$a -> array $a = error
array $a -> $a = error
: array -> (none) = error
(none) -> : array = okay
this is inconsistent
 
Sure.
 
we should probably add limited contravariance to parameters
 
We might.
NikiC has mentioned it a time or two.
I feel like usually it's an error, though, whereas the return type isn't.
But, I don't feel strongly about that (at least not at the moment)
Going from typed to untyped logically means you accept that type and more, right?
I understand that. In practice I wonder if that's what is really happening, or if it's a mistake (and I suspect it is the latter).
What do you think?
 
2:59 AM
narrowing the return types as in "() -> () : array" and relaxing parameter types as in "(array $a) -> ($a)" looks harmless to me.
 
Abe
3:11 AM
i'm not sure about that @marcio, c# disallows having a class method with covariant return type of a method defined in an interface, but allows covariance when relationship is between two classes (extends)
can't tell why though
 
@LeviMorrison allowing the removal of a parameter type means we can add parameter types to existing interfaces without BC issues
we can't add return types, but oh well
though implementations can
might write an email to internals about this
gn
 
3:34 AM
@Abe why you're not sure? removal of parameter types and addition of function return types is safe.
late here, gn :)
 
Abe
i'm just saying that c# disallows it, there must be a reason :P
gn!
 
Abe
dog damn pdo throwing exception and warnings at the same time...... ppppppppffffffffffffffff
and clearly, the important information is in the warning, not in the exception
 
Abe
4:21 AM
can't even error_get_last() because sometimes it triggers two notices AND an exception. lol wtf
*two warnings
 
Abe
4:40 AM
changed the logger, perhaps next time i will be able to fix this
 
Hii all. good morning
 
TIL: unlike implicitly initialized unions, explicitly initialized unions don't have their padding bits set to zero … C sucks. sometimes.
 
i want to need some information regarding the IVR
any one can give any information
I want to integrate IVR in Laravel with MongoDB database
any one ?
 
4:59 AM
moin
 
@JoeWatkins moin
turns out I still don't know all edge case behaviors in C …
 
Hi good Morning everybody
 
don't go near the edges, edges are sharp and dangerous ... just stay in the middle, you'll be fine ...
 
i have some doubts in url accessing
example.co.uk is the correct URL but cause of wrong folder structure
google took the url example.co.ukimages
 
5:06 AM
@JoeWatkins well… I'm on an imperfect circle of time… and moving unidirectionally… can't choose when I'll hit the next imperfection/edge.
 
and the google indexed this wrong URL (example.co.ukimages )
how could i remove this from google index
please help me here
 
@bwoebi things will look better once you have slept ;)
 
@JoeWatkins I have already
from 10 to 5 (CET).
 
I stare far too often at that column of yes votes in that void RFC
 
5:11 AM
why u no like it bob ?
 
@JoeWatkins cause null is better
I'd first like to see null voted on
The main-argument of void is "commonly used" … this argument is for me rather a tie-breaker than a strong argument.
 
null isn't a type
 
well, I think we discussed often enough that null is value and type
 
is there any language that uses null as you're suggesting ?
you can discuss it, doesn't make it so, it is not a type ...
 
@JoeWatkins JS gives an own type to null. C doesn't.
 
5:15 AM
in what sense ?
 
Abe
ruby (Nil), python (None) @JoeWatkins
and they are classes, not just "types"
 
@JoeWatkins in JS null is a value of type null (like PHP). In C it's a void pointer with value 0.
 
they are just languages with a different name for null
@bwoebi the fact that we treat null as a type is an implementation detail, just like we treat false and true as types ...
you wouldn't call false or true a type, would you ?
 
@JoeWatkins the type of true/false is boolean… But tell me… what's the type of null?
 
good morning
 
5:17 AM
it isn't, its a lack of type and value
 
Undefined type??
 
moin @Orangepill
 
@JoeWatkins so, null is not a value although you can compare against it etc.? After all, it's not like NaN.
 
Abe
@JoeWatkins no, they are classes
 
@AnmolRaghuvanshiVersion1.0 we have that too ...
 
5:19 AM
"null return type" means "lack of a return type or value". Makes sense ;)
now who wants to change /dev/null to /dev/void
 
null return type is the explicit lack of a return type...
 
I don't think there's much sense in trying to invent a way for php to do what a bunch of other languages are already doing ...
function () : null {
    return null;
}
is that valid, or invalid ?
 
valid for sure.
 
funcion () : null {
}
invalid?
 
null or void would be acceptable to me...just so there is a way to document the fact that the function returns nothing.
 
Abe
5:22 AM
it's invalid if you assign the return value somewhere imho
return; and return null; shouldn't be different
 
@iroegbu I would say it is valid.
@abe along with the absence of any return
 
@Joe even if you consider null to be the absence of a type, you can put return type null, to say that you want that… return nothing with a type ;-) … no reason to add void.
 
the rules are too complex, void means a specific thing, it's well understood, it will work as we expect, eventually ...
@Abe they are different
 
Abe
$x = (function(): null{ return null; })(); // fail, can't use a void call in a variable
$x = (function(): null|string{ return null; })(); // valid, because it can either be null or string
 
null can be the result of some operation, return $thing where $thing is null is not valid for a void function
it should not return anything but control with return;
 
5:24 AM
semantically I would prefer to have a void type whose value is null ...
 
we don't have unions yet ... that's a different thing ... string|void doesn't really make sense ...
 
with void return type can you assign result? Can't find that in RFC
 
at the moment you can
 
that's bad...
 
Abe
also this should be allowed:
function x(): null{ return null; };
function y(): null{ return x(); };
y();
 
5:26 AM
@Abe yep
 
so return $a would be a runtime error if $a is not null?
 
@Orangepill sure
 
@iroegbu little bit, but since it's conceivable that someone might be using a void function in an expression, we can't really change that right now ...
 
that seems odd... null return should be enforceble at compile time
 
agree with @Orangepill
must do walking dogs ... in a bit everyone ...
 
5:28 AM
TBH, I'd use an E_COMPILE_WARNING here, and error out at run-time.
 
I'd die hard :)
 
Abe
there is still hope @bwoebi it's 2/3 to pass
currently is 2.something
 
@Orangepill maybe. not sure.
 
Abe
class A{ function test(): void{} }
class B extends A{ function test(): null|string{} }
this is a legit use case for me, except that should be null and not void
 
@abe I have to agree that null .... "feels" better in that sort of use case
@bwoebi is it a true statement that currently ALL functions return null unless you explicitly return something else?
 
5:39 AM
@Orangepill yep
 
so return; and return null; are basically identical.
 
Abe
also - why as implementer should i care of how a "void" function is going to be used by its consumer code? how enforcing that will make my code and consumer code better?
 
void methods in interfaces
 
@iroegbu and the opcode for all three cases is identical.
but to me semantically they can mean three totally different things
 
5:47 AM
in 'humanspeak' they all mean different things
 
Abe
php must not be java!
php has to have what other languages have!
uncaught CoherenceError
 
@Orangepill from an interpreter perspective, yes.
 
6:23 AM
Anyone know how to clone an array of values that are referenced?
 
Do we have undefined type in php??
 
6:37 AM
@Abe except that's a violation of LSP
and hence shouldn't be allowed
@Orangepill I don't believe that's true. All functions produce null when you assign them to a variable. That doesn't imply that return; actually returns null. At least in a semantic sense.
@Orangepill totally disagree
@Abe if the return value is null, then yes. If it's void, then no
 
@ircmaxell The semantic sense is nowhere defined, except in implementation where an explicit ZEND_RETURN null is added.
And I prefer viewing functions as implicitly returning null if not explicit (callee-side). Instead of "if no value was returned, assign null to the returned temporary (aka at caller-side)".
 
@Abe "you can't use a void call in a variable" <-- why not?
@bwoebi null is the explicit lack of a value. If you assign a void function (one without a value) to a variable, you get an explicit lack of a value as a result
 
so, why shouldn't be a null returning function… as null means explicit lack of value and thus should be semantically equivalent to you?
 
@bwoebi sure it is, it's defined because return; doesn't say what it returns. Therefore, it returns nothing. Defining it as "returning null" is an implementation detail. That's not semantic meaning. The semantic meaning is "no value". And the common (not just PHP interpretation) of assigning "no value" to a variable is either undefined or null.
@bwoebi because the function isn't returning null
it's returning nothing
the fact that nothing gets turned into null is something that can be perceived to be happening on the receiver side
 
@ircmaxell sure, and you're saying the nothing is defined as null inside PHP ecosystem.
 
6:47 AM
Hello
 
@bwoebi no
 
@ircmaxell disagree here.
 
@bwoebi I'm saying that nothing, when interpreted as a value is null. It's not null itself though, because of implicit vs explicit
 
may i know how to integrate IVR with laravel 5.1 ?
 
I'd like to distinguish not existing (which is casted to null with a notice in every case) and null.
 
6:49 AM
@bwoebi @bwoebi when you look at other languages, when you look at databases, when you look at mathematics (set theory, lambda calculus, etc) they all make that distinction. This is the only case I've ever seen argued that void and null are the same thing
@bwoebi it's not a notice in every case though
 
@ircmaxell That's the issue of having no clearly defined semantics for PHP...
we're all defining our own semantics based on what we read and get…
 
@bwoebi ummm... if you knew nothing about PHP, and I asked you "what does return; do", the chances are quite high you'd say "return nothing"
 
@ircmaxell now ask him what he thinks function f() { return; } var_dump(f()); does and tell him to explain how this should work with returning nothing.
 
that's a different case, because you're trying to use the value of nothing in a context
 
@ircmaxell no? except arrays on null/false
which is anyway weird…
 
6:53 AM
@bwoebi no, not every case. pass a non-existing variable by reference and what do you get?
 
@ircmaxell reference creation is initialization though, not value using.
 
@bwoebi thin line
very thin line
the point is void has a different semantic meaning from null. Saying (): void imparts specific assumptions about that function (assumptions that we desperately want). (): null imparts none of those assumptions. That alone is worth it. But then add in that (): null makes less sense and is weird when you look at every other typed language out there, and that makes void a clear winner on all fronts
 
@ircmaxell I'm thinking they are the same within the semantics of PHP… but obviously that depends on how you define PHP semantics...
 
@bwoebi they are not the same
not by a long shot
 
depends on how you define PHP semantics
they are not the same in general context, I agree there.
 
6:59 AM
with (): null, a very strong argument can be made that return null; is acceptable. And a very strong argument can be made that $a = null; return $a; is acceptable. And return functionThatReturnsNull();. And all of those are very different from the implication of void which says "nothing" and hence all of those statements should be illegal
 
I'm just talking PHP now though.
 
@bwoebi you haven't proven how PHP needs to be different from the general context though. Making it different "just because" isn't good enough.
 
@ircmaxell by saying that PHP semantics define that a callee always returns a specific type and never an absence of any type/value.
 
that specific type is the absence of any type/value That's the definition of null in type theory
 
thus, we should have a null return type, because we expect the absence of any type/value then.
 
7:03 AM
ok, I'm done
 
Or what exactly is void, when not precisely the absence of any type/value?
 
void is the implication that this function doesn't return anything
not that the function returns the type that signifies nothing
there's a difference
hell, our own bloody documentation and source code uses that semantic
 
I'm considering it like we have a return value pre-initialized to null, which we can set, but not read… always when we explicitly return, we can overwrite it. Also fits IMO nicely with behavior observed with multiple returns possible due to try/finally.
@ircmaxell ... source code? or do you mean the fact that it's C code?
 
no, I mean in the source code, method prototypes, etc
 
I must admit I very rarely look at these…
 
7:06 AM
 
moin (v2)
 
ok, I'm done. I need to shower and eat and then conference
 
@ircmaxell just a question… is null a type signifying nothing or nothing?
 
@bwoebi null is the explicit lack of a value
 
@ircmaxell see you later… sorry for the eventual headaches…
 
7:07 AM
@bwoebi the point is void is everywhere, even in PHP. To say that it's not is to not have opened your eyes
 
@ircmaxell I didn't say that. I just said that I don't know much about the method prototypes in source.
 
time for a new phoid type I think ... can be null, nothing, undefined, a picture of a cat, or int(42)
 
@ircmaxell yea, I believe you … just I didn't know ;-)
@ircmaxell I'm just a bit conflicted here, I've always seen void as nothing with meaningful value and type information. But it's still something, just that it doesn't have any meaning… The absolute nothing IMHO doesn't exist… Meh, I'm just discussing myself ad absurdum here.
And I should make attention to not drive Anthony crazy :-D (twitter.com/ircmaxell/status/659991060400205824)
nah, seriously, I'm going crazy myself too, because I'm not sure if I have some fundamental misunderstanding or if there's a fundamental flaw in Anthonys logic.
The only thing I'd really like to complain about is that @Andrea did a poor job about explaining why void and not null. "customary" is maybe a tie-breaker, not a "main reason". And for "function is supposed to not return a value, rather than return null specifically", I just can say "yeah, but it does return null and not not a value."
 
7:28 AM
@bwoebi believe me, I question that as well. The one reason I'm confident here, is that it's how every other language works, and it's how type theory works (at least as much of it as I've studied)
 
Sometimes I feel like these things are very high-level philosophical questions … and it ultimately doesn't matter much.
@ircmaxell hmm, other languages with void type also return null when the a return value is used.
(when used via dynamic dispatching I mean)
don't know. I've retracted my vote for now. I now truly am unsure what's correct…
The moment after overthinking everything so much that you can't differ the good from the better anymore…
 
7:45 AM
@bwoebi take a break and come back to it with a clear mind. Often the best way to determine these things is to try them both out in context, and go with whichever feels and looks more intuitive. (If analysis is inconclusive)
By the way @JoeWatkins, I feel bad for the number of assigns I've made. I'd buy you a handful of beers if I could. Or cake, etc.
 
@rtheunissen the problem is they both are intuitive depending on the point of view.
 
Handful of beers being one, I just realised.
@bwoebi that's the predicament. :S
 
yup.
@rtheunissen you should really try cake… people always just offer beers ^^
 
I've ordered pizza a few times.
 
:-D
I feel like the discussion void or null is like the philosophical question whether the absolute nothing exists…
 
7:52 AM
I feel like internals have a habit of forcing a discussion out, with the help of a few people who just argue with absolutely everything anyone says ... Stas ... even when something is a done deal ...
 
It comes down to what you're trying to communicate, though. Absolute nothing exists, it's the void, it's the complete absence of... anything, including nothing. Until the day we send some poor robot beyond the event horizon, the idea of "void" is the best we can do to communicate nothingness. I think of null as a value, void as a type, and null as the value representation of the type. Either way, can't wait for : void :)
 
@JoeWatkins you maybe should leave some hint how to include modules (pthreads in this case) just for one specific SAPI (cli)
> If php-SAPI.ini exists (where SAPI is the SAPI in use, so, for example, php-cli.ini or php-apache.ini), it is used instead of php.ini. The SAPI name can be determined with php_sapi_name().
 
you can comment on stuff ...
 
the docs hide all the information… the issue is just that nobody knows where.
@JoeWatkins meh, don't remember which issue it was… too lazy to search it again ^^
 
I updated it anyway, thanks ...
I'm going to have to repeat that a million times most probably ...
 
8:00 AM
@JoeWatkins which is why you should indicate it prominently at the top of readme, I guess.
 
yeah, probably
 
posted on October 30, 2015 by nlecointre

/* by Nauris Andzans */

 
Hey guys. Need some help with PHP operators ordering and grouping...
 
@ЗахарJoe what's your precedence issue?
 
So I'd like to evaluate an expression in round brackets against another like so: while ( (cond1 and cond2 and cond3 ) and cond4 ) {...} but it doesn't work. Instead I get while ( cond1 and cond2 and cond3 and cond4 ) {...}
But I want cond1,2,3 to be treated as a single entity.
Totally stumped. It just doesn't make sense to me.
 
8:14 AM
hai every one... i need help for video url validation... please help me
 
I mean, even if I put round brackets around those it still treats the overall while contents as a single chain.
 
@ЗахарJoe That doesn't make sense to me… multiple conditions as single entry?? and is an associative operator.
 
@ЗахарJoe Try storing the conditions as two separate variables and see if that produces the expected behaviour?
 
@bwoebi Yep, I really don't want to bother you with the details as my head is about to explode already, but if you need to know the whys, it's because I'm iterating through a string and the algorithm upon finding a dot, a question mark or an exclamation sign FOLLOWED by a space would trigger exit. For that particular description there's a workaround, but I would need to stack up more conditions like that, so I can't just make three "cases".
@rtheunissen good idea, just a sec.
 
please i really want answer.how to valid remote video url validation please help.
 
8:19 AM
@rtheunissen Nope, same thing.
I put them inside a while loop and as expected it does one more pass. But the behavior doesn't change.
 
@ЗахарJoe That indicates a flaw in your logic itself.
So you're iterating through the characters of a string, and exit when there's punctuation followed by a space?
 
@rtheunissen I doubt it. I have a working prototype in FileMaker which uses exactly the same logic save for the fact that FileMaker wants to "exit loop if" and PHP does "while some condition".
Yes, in this simplified case that's exactly what I'm doing.
 
Could you do a while (true) with a if (...) { break; } ?
Are you accessing the characters by index?
 
@rtheunissen I could do that and I could rewrite it using a switch statement, but I'd rather try to be terse if that's possible and stuff it all inside a while loop.
Not sure what you mean by an index, it's a simple mb_substr function that receives a current position in the string to evaluate.
 
8:24 AM
Could you give us a very small example? It's hard to provide feedback otherwise.
 
while ( ( letter () != "." and letter () != "!" and letter () != "?") and letter (1) !=" " and $textposition <= $length ) {
$result = $result . letter ();
$textposition++;
}
function letter ( $skip = NULL ) {
global $textbook, $textposition;
return mb_substr ( $textbook, $textposition + $skip, 1, 'UTF-8');
}
 
I'm not sure, but would there be a difference between and and &&?
 
Nope, didn't make a difference.
 
@rtheunissen no difference
moin @Jimbo
 
Having not used and, wasn't sure.
 
8:28 AM
But even then I need more, the final thing would look like while ((( cond1 and cond2 and cond3 ) and cond4 and cond5 ) and cond6 ) {...}
 
I tried some explaining @rudi
 
@ЗахарJoe what's letter()?
 
@rtheunissen it's equal to return mb_substr ( $textbook, $textposition + $skip, 1, 'UTF-8');
 
@ЗахарJoe When you start doing things like that you should step back and re-evaluate because you're on the wrong track.
 
while letter (1) is equal to return mb_substr ( $textbook, $textposition + 1, 1, 'UTF-8');
sorry, letter(1) is equal to return mb_substr ( $textbook, $textposition, 1, 'UTF-8');
aw! letter() in the second line, equal to return mb_substr ( $textbook, $textposition, 1, 'UTF-8');
@rtheunissen, I'd be glad to listen to your suggestions.
 
8:30 AM
I would suggest: only check against the length in the while, and determine the exit condition within the loop.
 
dude ... that's awful
 
Or at least have the length be the first check in the condition.
Also, cache the current value of letter() so that you're not evaluating it every time.
 
looks like a parser of some kind ... you really do not want every letter to cost 3 function calls ...
 
@Joe Watkins it is a parser. It breaks text into sentences and there are more conditions that arise while it scans through a sentence.
@rtheunissen I agree about caching.
Right now though, I'm trying to understand why it doesn't like round braces in that context.
The whole idea of breaking out of loops is equal to GOTO statements in my head.
 
I can't see why they are there ...
 
8:34 AM
Especially when this breaking should occur not somewhere inside the loop but right after your while ()
 
morning!
 
goto is a totally valid thing ....
 
@Joe Watkins they're there because otherwise the loop would match a single space and I need to match a space only when it's preceded by a punctuation character.
 
nobody will even shout at you for using goto in a parser ...
 
That's what it's doing right now - matching a single space and stopping.
That could be true, nobody would, but I just don't like that kind of logic. It's not too impossible of a task, and FileMaker for some reason understands the precedence must be honored when I put round braces around conditions. But PHP just ignores them.
 
8:37 AM
Any one please help, how to find given any remote video link have video in vaidation
 
example input and what you expect to get @ЗахарJoe
 
Sure.
$textinput = 'This is a simple sentence. And here's another one.'
 
@ЗахарJoe what about something in this direction:
 
The result I'm expecting:
 
$prev = '';

while ($pos <= $len) {
    $letter = letter();

    if ($letter === ' ' && in_array($prev, ['?', '!', '.'])) {
        break;
    }

    $prev = $letter;
    $result .= $letter;
    $pos++;
}
 
8:39 AM
after the first loop $result == 'This is a simple sentence.' second pass: 'And here's another one'.
@rtheunissen That could work. But I need more than that. There are special cases for sentences with quotes and I use another condition that checks if the quotes have been closed at any particular point inside the string while doing the loop or not. And even more...
 
@JoeWatkins moin moin
 
So that would make a lot of 'if's and I already managed to do that with "while" alone, only not in PHP.
 
@rtheunissen well, still a lookup there, better to make a few comparisons I think ...
 
@JoeWatkins "direction"
 
Here's how it looks inside a FileMaker script (and it actually works):
( ( ( ( Middle ( Sourcetext ; $textposition ; 1 ) = "!" or Middle ( Sourcetext ; $textposition ; 1 ) = "?" or Middle ( Sourcetext ; $textposition ; 1 ) = "." or Middle ( Sourcetext ; $textposition ; 1 ) = "…" ) and ( Middle ( Sourcetext ; $textposition + 1 ; 1 ) = " " ) ) or Middle ( Sourcetext ; $textposition + 1 ; 1 ) = "¶" ) and not IsEmpty ( $quotes ) ) or $textposition > Length ( Sourcetext )
 
8:44 AM
I'd just keep an incrementing int, with a substring at the end, and look up by index.
@ЗахарJoe Concise is good, terse is not. That code doesn't communicate what it's trying to achieve.
 
@rtheunissen please clarify what "look up by index" means, I'm not familiar with that notion.
 
$s = 'abc'; echo $s[1]; // b
 
@rtheunissen It's probably true, but it's really a matter of grouping conditions to dictate precedence. Like in mathematics: ( 2 + 10 ) / 2 = 6; 2 + 10 / 2 = 7.
 
Grouping conditions works just fine in PHP.
 
@rtheunissen so you propose an array. Well, apart from probably making it a bit faster, is there a difference?
And so I thought that it should work just fine, but in my case it simply ignores the braces.
The other reason why I'm trying to make it work is because I want to understand the language. It may be easy to work around that in one way or another, but it's also important to understand why this precedence doesn't work to avoid making mistakes in the future.
 
8:51 AM
Accessing the string by index, keeping a start and end value, with a substring at the end would be your fastest, simplest solution. You may run into multi-byte string being weird but I'm not sure. As for the problem of when to actually break or end, multiple if blocks with a break for each is a decent start.
Don't shove it all into a while.
 
@rtheunissen All right, I get it. Still, if we forget about what's right and what's wrong for the moment, why exactly doesn't it work like I intended it to? Is that something in PHP? Is that something else?
I sure didn't see it documented anywhere.
 
Fair enough. I can tell you that it's not the fact that the precedence doesn't work. It's that the condition itself does not reflect what you think it does.
Your test itself is flawed, rather than the mechanics of the test.
 
20:7!
 
@rtheunissen Soo... what does it reflect then?
Where's the flaw?
 
That's for you to debug. :) Break it into smaller parts, which you can also wedge into a while loop later on.
 

« first day (1840 days earlier)      last day (3114 days later) »