« first day (1812 days earlier)      last day (3130 days later) » 

12:00 AM
it's one if() and one return line with a conditional.
 
Then don't worry about it...imo.
 
kk, thx
 
Hi All
I have just started learning Php and I am stuck with some simple regular expressions
 
@SonuKMishra what's the question?
 
I am just trying to validate a number (integer or float). This is what I have written:
$number = '[0-9]*(.[0-9]*)?';
$ret = preg_match('/^'.$number.'$/', '-1.1');
echo $ret;
I get 0.
 
12:09 AM
@SonuKMishra have you looked at php.net/manual/en/function.is-numeric.php
 
you're not accounting for the leading -
 
However, if I put -1, then I get 0. I don't understand why
@crypticツ, since I am learning about regular expressions, I want to solve this using regexp only.
 
fair enough.
 
if you want a really good book on the subject I can't recommend amazon.com/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/… strongly enough
 
@PaulCrovella, do you why -1.1 is producing 0 while -1 is producing 1?
 
12:13 AM
/-?\d+(\.\d+)?/ try that
 
Hmm...let me try
 
btw \d is the same as [0-9]
 
@SonuKMishra -1 is actually matching on (.[0-9]*) as the . there matches any character - to match a . specifically you need to escape it like \.
 
ohk
I got it. Thanks a lot guys!
:)
 
your regex is also going to match an empty string as everything but the start and end anchors are optional
 
12:18 AM
^ doh, forgot that =oP
 
likewise with stuff such as 2. - dunno if you want that or not
 
Thanks for pointing out the errors.
 
@SonuKMishra regex101.com/r/qA9oK5/1 nifty site
you can quickly test against a list of values and also the sidebar details how the matching is done.
 
@Andrea somebody asked a similar question on reddit: en.reddit.com/r/PHP/comments/3n3scc/…
 
12:23 AM
@SonuKMishra No worries. It'll help you a lot to step through your regexs bit by bit and think about exactly what each piece will match (and won't), and how that might not necessarily jive with what you're trying to do with it.
 
short version: the closure RFC gives us all the benefits right now....without having to get a massive RFC through internals.
 
@Danack ehhhh
yes, but it's a hack
and it's not even something we need internals for
 
\o/
 
you can implement closure() today, in userland
 
Yes, I have. It's horrible.
and slow.
 
12:25 AM
it can be optimised ;)
 
I'm not sure it can be optimsed as well as it could be if it is included in core. Opcache could optimise things like closure('foo') completely away....
for functions that don't have static vars.
 
more to the point...
why use closure('foo') over 'foo' anyway?
The latter's actually faster
And less verbose
 
Hmm?
Not sure what you're asking.
 
Why would you use closure()?
Just using the plain callable works better
Why do array_map(closure('...'), ...); when you can just do array_map('...', ...); ?
 
You wouldn't do it like that.....it's for when the generation of which function needs to be called is separate from where it's used.
And also to dis-ambiguate whether it's something that needs to be called or a string.
 
12:31 AM
are the old wacky callables still necessary in a world where we have closures?
 
@Andrea it reminds me of what my essays looked like, when I got them back from teacher
 
@tereško red lines everywhere? yeah, I've been there
I apparently use commas too much
 
function foo() { }

function getFooInfo() {
    return closure('foo');
}

$fooInfo = getFooInfo();
if (is_closure($fooInfo)) {
    return $fooInfo();
}

//Already data, safe to return
return $fooInfo;
 
@Danack this is a poor example because the return type could make it clear :p
 
12:33 AM
I see how this could help readability, though
 
Not all stuff is return-type-able unfortunately. But being able to tell the difference between someone meaning to return a string, and meaning to return an invokeable thing is useful.
 
... and now I will take my old ass under covers and try to sleep
o/
 
@PaulCrovella now that's a good question.
 
@PaulCrovella yes, because not all PHP functions are closures, at least for now
 
12:35 AM
A significant number of people to seem to be hung up on the bit in the manual that says closures are 'just an implementation detail'.
 
That should change, they have methods these days
 
@Andrea sure, but you can still wrap a call to any of them in a closure and use that
may be more verbose, but I like it a lot more than throwing strings around
 
btw @Andrea at at least one person in that reddit thread has their own implementation of callable -> closure, and they seem quite supportive of the RFC, as it makes their API library, which only accepts closures as callbacks more acceptable to the community.
 
yes I can understand why that'd be nice
I just don't think this is the right way to go
 
something something perfect enemy of the good something.
 
12:44 AM
if you must do this, make it Closure's constructor
 
Glad to see you read the rfc.
 
> Using a plain function allows more flexibility in the implementation, without having anything be inconsistent.
?!
Oh, returning the same object
I mean, I guess
@Danack make it a static method, then
Closure::from('strlen')
Closure::from(['FooClass', 'barMethod'])
this is nicely readable as well :D
I feel this should be part of the Closure class. closure() is cute but that's not a good enough reason to keep it separate
 
"this is nicely readable as well" - No it's not. And the RFC lists reasons why a function is better. If you want to persuade me that an OO method is better, please say an actual reason why it's better.
 
> No it's not.
"Closure" isn't a verb
But "Closure from X" is a noun phrase
 
> If you want to persuade me that an OO method is better, please say an actual reason why it's better.
 
12:51 AM
@Danack Why is it better? Simple. Why is there a magical global function that produces closures?
In OOP you group data and the functions to deal with it into a class
If I made a new global function call which takes a Closure and an object to bind to, people would rightly ask why it wasn't called Closure::call instead
If I made a global function listFromArray which takes an array and produces an SplDoublyLinkedList, people would ask why it wasn't a method of that class
 
@Andrea Right. But the closure() function doesn't take a closure as an argument, so that comparison is bogus.
 
@Danack No it isn't.
closure() is a constructor/builder/whatever
it produces closures
 
No, it's a function that creates closures. The implementation details are hidden.
 
that's a constructor
 
strlen is a function that produces numbers.
But we don't do Int::fromStringLength($str)
 
12:55 AM
primitive types aren't OOP
talk about actual classes.
 
And neither are invokable types.....
The fact that it's a closure is an implementation detail.
 
Closure is a class, though
 
btw there's another reason which I forgot to add to the RFC:
 
@Danack yes, and that's also nonsense since Closure now has methods
and people actively require closures in tyoe hints sometimes
 
procedural stuff is easier to chain together:
Sep 12 at 16:02, by Danack
function createClosure($callable, $name) {
	$callable($name);
}

createClosure('closure', 'bar');
createClosure([$closureMaker, 'foo'], 'bar');
 
12:56 AM
@Danack that code doesn't do anything
what is it supposed to do?
 
blah - that was an argument against new.
wrong argument then.
 
???
 
people were suggesting new Closure($callable)
which isn't a callable.
 
hmm, isn't there a workaround for that, though?
 
Yes. Using a function and not being obsessed by OO.
 
1:00 AM
explain please why we should break OOP principles
what is wrong with the existing conventions?
 
> e.g. in cases where the same function is turned into a closure twice: with the implementation being a function it is perfectly acceptable for $fn1 and $fn2 to be the same object. If instead the implementation was as a constructor for the closure class:
 
@Danack that applies for the constructor
okay, make it a static method then
now you're good, right? what's wrong with that?
 
> Additionally having it be just a function, would make it easier in the future to implement it as a language construct, which might be desired for performance reasons.
You aren't going to persuade me of making it be something other than a function unless you can tell me something it either allows or some other concrete benefit. Just saying that we need to stick to 'OOP principles' is really not convincing.
 
@Danack performance? Opcache can inline
 
@Danack unless you're actually proposing it as a language construct and have something showing an actual performance gain, that looks more like wishful micro-optimization
 
1:05 AM
and, in fact
a language construct couldn't be faster, anyway
for the constant parameter case, opcache can optimise it
for the variable parameter case, nobody can
also, why would we make Closure into a keyword? We already have callable for this purpose
 
@Andrea please no more ::stuff
 
@PaulCrovella It could be a compiler optimisation - which is beyond my ability to implement, but I will be prodding people to do it. It will need to be able to inspect the parameter as to whether it has any static vars, and then generate appropriate code to generate the closure.
 
@Danack we don't need a language construct to do this
you pointed this out yourself
opcache can optimise the function call
heck, not even opcache. the Zend Engine III can
Benefits of making it a language construct: none
 
s/language construct/engine optimised implementation/ then.
 
Downsides: backwards-compatibility break because it's now a keyword
@Danack that doesn't require it to be a function, though
we can optimise Closure::from or new Closure just as well
better, actually
we can't optimise closure(...) usually, because of namespaces and fallback
we can optimise new Closure() or Closure::from() because classes don't have namespace fallback
so, actually, it would be better NOT to use a function, from an optimisation standpoint
 
1:10 AM
As I said, if you can think of actual benefits from usingClosure::whatever over a function, I am all ears.
 
@Danack I just gave you one. It can be optimised
closure() can't unless you aren't using namespaces, or you're prefixing it with `\` which nobody does
I can see you about to say this isn't an actual benefit
But you just told me right now that optimisability was a benefit of using a function
So...
to recap:
not using a global function is more amenable to optimisation, and follows PHP's existing principles
using a global function is inconsistent with PHP's naming conventions and OOP principles
and I need to sleep
goodnight.
 
and, quite honestly, even dismissing the OO argument as just "obsession" is kinda irritating - no different than someone dismissing you as just obsessed with being contrarian about it
 
@nikita2206 did you manage to solve the (int) edge case?
pff this is so pedantic news.php.net/php.internals/88631
 
1:32 AM
@PaulCrovella sorry - I got fed up with people insisting use new closure for multiple hours the other day.
@marcio I was just about to ask if anyone knew who he was, from a totally different subject.
oh, he's on SO.
 
@Danack No worries. I get the frustration.
@marcio I don't understand what's pedantic about that
 
> it will cascade to exceptions in the documentation, plenty of SO questions, and probably a PHP Sadness
 
he's not wrong, though I don't give two shits about phpsadness
considering all the bizarre nonsense that's come up on that thread, I'd say that email in particular puts forward his position in a reasonable, understandable way
 
heh, strongly disagree.
> I'm saying that, in PHP, that's how its done. It's different from other languages, which can be confusing, as online documentation comments show.
 
1:44 AM
you disagree with his position, that he put it forward reasonably, or that the position can possibly have a reasoned argument for it?
 
this false preoccupation with cognitive overload is out of the league, it's just FUD like always. I won't get involved in any argumentation related to this anymore.
 
a little preoccupation with language consistency certainly wouldn't hurt PHP
 
@PaulCrovella this was his last proposal 'fn($a, $b @ $c) => $a + $b + $c;' ^^
 
yeah, and that's awful. maybe you're railing against the wrong email.
 
no, but you're free to do any interpretation you want.
 
2:00 AM
okay, I think you want a thing and because of that you're willing to completely disregard the possibility that there might be any downside to having it at all rather than honestly weigh the pros and cons.
I think levi's proposal probably comes out as a net positive. I also think bob's proposal would've stood a better chance if concerns brought up about it weren't simply dismissed for as long as they were.
 
Abe
2:25 AM
morning
 
morning Abe
i.stack.imgur.com/JOuSY.png what it's showing
 
@Danack I have to say I quite like the idea of new Closure(callable $callable). Each call will have to return a new object, but this probably isn't such a bad thing.
But it doesn't really offer any advantage over closure(callable $callable), so meh.
 
2:43 AM
good morning
 
morning o/
 
Hi All,
 
I am new to php and am writing a simple code to evaluate mathematical expressions.
 
any php internals people in here?
 
2:48 AM
using eval() function.
 
if eval is the answer you are asking the wrong question.
 
I understand that eval function can lead to various security issues, but I have to use eval function only. It's kind of compulsory.
I just want to detect division by zero error in eval
as in eval (1/0)
 
this might be a more sane solution then using eval
 
tengenengyen
 
Abe
2:58 AM
user image
10
 
@PaulCrovella really? I've been questioning for days why they think auto import is an issue and really tried to understand all that was presented but none of the reasons presented were important enough. If you think raising FUD like (unproven) cognitive overload, "plenty of SO questions" and "another PHP sadness" will be created or "it's been like this for 20 years" is being reasonable, then let's disagree. Just don't pretend you know my opinions better than me, that's inappropriate.
 
good morning
 
fence post error
Anyone have suggestions on a MacBook for dev work.... looking for a good value not a bitchin machine
 
3:16 AM
@marcio the only one I've seen mention cognitive "overload" is you - the dude just said there's a higher cognitive load, so maybe leave the straw man out of it
or kick and scream about FUD, I don't even care anymore
 
3:43 AM
happy friday room 11
 
 
2 hours later…
5:59 AM
yaaay!
\o/ Happy Frydai 11!
 
Roomies seems to be very busy today...^^
 
6:21 AM
Morning
 
morning
whats wrong with this update query?
UPDATE i
SET i.photo = REPLACE(i.photo, 'pictures', 'instagram_images/1')
FROM insta_images AS i
INNER JOIN photo_album AS pa
ON (i.photo_id = pa.photo_id)
 
6:48 AM
Starting right off the bat huh Joe?
 
Morning
 
moin
 
@JoeWatkins how can I specify return type hints internally?
Can't seem to find anything on it, or anything that does so internally.
 
ZEND_BEGIN_ARG_INFO_WITH_RETURN_TYPE_EX
 
7:02 AM
Perfect thanks.
Hmm doesn't show up in lxr.
 
sorry
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX
 
the former would be too sensible for php I guess :)
 
Should have guessed. What are the ARG_INFO macros used for anyway? I'm keeping them around without really knowing what they're for. Typehints?
ZEND_ARG_INFO(0, index) I'm guessing the 0 is the typehint. to lxr we go
 
zend_internal_function.arg_info, reflection
ZEND_ARG_INFO(pass_by_reference, name)
 
7:06 AM
pass by ref (int)
 
yeah
you will probably never remember them all ... I don't ... you'll probably never use them all either ...
 
Are typehints enforced by zend_parse_params*?
 
it depends, it's down to you to make them consistent
 
Instead of 'z', eg. 'a' would be the equivalent to func(array $arr)
Just poking to gather the convention for this stuff
 
assume that it doesn't, and make sure they are consistent ...
yeah
 
7:08 AM
Cool, doing that.
 
I don't know what amuse me the most, when people come to SO to learn to "hack" or when they expect us to teach them.
 
Thanks
 
Hrm, out of curiosity, if a user asks us how to hack something, and then after being informed that is not what we do, he simply rephrases the "how to hack" part into a more innocent phrase, is it still viable to flag / close / w.e due we know it's gonna be used for "bad means" ?
 
Morning, o/
 
@Epodax context?
moin @Duikboot
 
7:16 AM
-1
Q: hide email form input for registration

daniel321I am looking to recode a php script I'm using to hide email form input on a script. Like many php scripts, it asks for an email address to proceed however I'm trying to make it simple and remove it – I set a default password and hid it or put the password on opacity: 0 - thus the person enters ...

Look at the revision history.
 
the question is nonsensical, close it for that reason ...
 
"hi thanks for clicking - real quick i would want I am looking to hack a s"
 
Righto
 
Someone an idea how I can set a Font in my .vimrc file? Or is the used font set by my Terminal?
 
setting up a repo with vagrant and a weak web app for testing/practice/learning web app security .. any idea for a good name... so far the best I have come up with is "VulnWeb"
 
7:24 AM
@RonniSkansing @Danack @PaulCrovella thanks for feedback. I'll forward it.
 
No problem, tried out the app with the linkedin login, it is very cool
 
thanks. we'll make it even better in the weeks to come. it's a very early version
 
Is there a big difference in using Zend vs Laravel?
 
What app? @Gordon :D
 
7:29 AM
morning
 
morntngin
 
on a completely unrelated side note, this is hilarious:
I forgot to turn off notifications. Twitter sent me an email for each: Follow Favorite Retweet DM 47 gigs of notifications. #lessonlearned
 
@Gordon oooh, looks nifty, it's server monitoring tool?
 
out to walk dogs ...
 
@Epodax yes and it maps out your entire logical and physical network.
 
7:37 AM
@PeeHaa got a few seconds, I had a strange problem yesterday but still not sure what the exact problem is/was
 
@Naruto Sure
 
@Gordon Looks sweet. when will it be available? :D
 
\o
 
@Gordon does it handle VLANs and VPNs and the likes? Which port needs to be globally opened?
 
@PeeHaa - You know what I ment by hacking >.<
 
7:45 AM
Morning.
 
o/ @MikeM.
 
I've seen 2 kinds of company: those who have a home-like network where they don't care because everything is online, and those who have hugely complicated networks with a sysadmin team and all the stuckness that goes with it
 
\o
 
@Gordon is it a monitoring tool like newrelic?
 
Hi. Anyone knows why the array $db_name is empty in this code:
http://pastebin.com/Ezwc8E2g
 
7:49 AM
Check the first line
you write a new array.
Then you do nothing with it beyond printing it
 
either you don't enter your if-statement
 
never mind
it's most likely to be that.
 
@MikeM. $db_name = $query-> fetch_all();
 
or $query-> fetch_all(); isn't returning what you think it's returning
 
@AlmaDo yes and no. we intend to make our tool more accessible so you dont have to be a data nerd to make sense of it.
@Epodax it will be available for everybody mid 2016, it is currently in closed alpha and we have a backlog of closed beta customers.
 
7:50 AM
ah yes, was going to test gordons new workarea
 
var_dump($query->fetch_all());
in the if-statement
The first line in the if-statement add: echo('IF Statement entered!');
 
user1804599
With return type declarations, is it possible to specify that a function must return NULL?
 
@Gordon why do you want access to my linkedin when using your demo? :( :P
 
@MikeM. It enters the if Statement.
 
http://pastebin.com/9BcaXXbj
What does the var_dump return?
 
@Naruto because marketing wants to know whos trying
 
@Epodax :P
I know
Still I don't see what's ethically wrong with the question
 
Pfff those random spaces in your code ^^ annoying.
 
@MikeM. looks fine in my IDE
 
@FlorianMargaine yes, it does autodiscovery so its aware of network topologies. it requires an outbound connection to our cloud servers to collect the data from any server you run an agent on.
 
7:55 AM
@Gordon well looks nice, seems to be pretty handy in tracking some failures
 
However you fill your $db_name (wrong name anyways....) the only possibility would be that the if-statement is just being ignored...
because you set it with an array
 
@Gordon awh, so long to wait!
 
@Naruto we intend to add much more features for that purpose
 
Btw why do you have a random die in there? XD
 
@MikeM. for debugging. XDebug don't work sadly
 
7:58 AM
for debugging I would just do "die(var_dump($db_name)); # returns "Array()".. Why?" instead of printing it and then die. but that to be out of the way.
It's strange
Other than what you gave us, it should work.
 
@MikeM. Okay, Thanks for the hint, I'm relatively new to PHP
 
@Gordon will you offer a self-hosted solution?
 
@MikeM. Yep, that's why I'm so confused.
 
posted on October 02, 2015 by nlecointre

/* by clochemer */

 
@Gordon hm.. but that's a tradeoff. How will you achieve their level of details without making things complex?
 
8:01 AM
@Gordon and most importantly, do you have a feature comparison with nagios? :-)
 
(asking since I'm an active newrelic user)
 
@FlorianMargaine idk yet
 
@MikeM. But thank your for the help, I hope I find the problem
 
@FlorianMargaine internally probably. would have to check. bear with me, its my second day ;)
 
@Gordon no problem, just mentioning that your product is already a crowded space
 
8:04 AM
@AlmaDo that's the challenge, but the idea is to crunch that all that data for you, so you dont have to
@FlorianMargaine crowded space?
 
@Gordon will it have some data-analysis tools like graylog ?
 
@Gordon yeah, several competitors
 
@FlorianMargaine true but the market isnt saturated yet so lots of opportunity to grow
 
@Gordon That looks like a cool product to work on
 
user1804599
@elyse Oh, void RFC.
 
8:07 AM
@AlmaDo likely. but more in the way that we do that for you. not sure yet.
 
@elyse yah, but not yet
 
@PeeHaa thanks. It's a lot to get into right now for me.
 
user1804599
> Status: Withdrawn :[
 
user1804599
@NikiC why not
 
8:23 AM
@Gordon keep us posted :)
Aaah friday gotta love it ^^
 
@salathe c
 
@NikiC :)
 
moin new peepz
 
hallo old peep
 
@Naruto can do though I dont wanna turn this into an ad channel ;)
 
8:30 AM
@salathe Just to clarify, you want "\u{10000}" to be "\xf0\x90\x80\x80" and "\u{11000}" to be "\u{11000}", yes?
@elyse ah ... because php?
 
yup
 
@elyse Mainly because a) timing and b) certain people have very odd ideas and want to have : null instead of : void
 
can I have one of those floating robots for my office please @Gordon ... kthnx ...
@NikiC if we, humans I mean, entertained every stupid idea, we would never get any real work done ... it's okay to ignore stupid, if it's stupid for stupid's sake ..
 
o/
 
@JoeWatkins I think there will be swag eventually. at least I got a sticker for my notebook.
 
8:34 AM
<3 swag
@NikiC was is stas ?
 
@JoeWatkins I think so. And Levi
 
null is a value not a type, end of story ...
 
just an occasional update ^^ or either pm me :)
 
@JoeWatkins Levi might argue that it's both
 
: "the string" ... it doesn't make sense ... ignore it ... I'd really like :void for completeness ....
@FlorianMargaine levi would be wrong
 
8:39 AM
@Andrea You mind if someone (maybe me) takes over the void RFC?
 
just fyi ... attending phpnw so probably be a wait for a response @NikiC
(travelling today I guess, I'm sure you knew she was attending)
 
@JoeWatkins I knew she's attending, but I didn't know that phpnw is now ^^
 
starting this evening, but she's gotta go a long way ... probably be on trains until late afternoon I guess ...
 
@NikiC it's the tutorial day today, before the main conference
 
user1804599
@NikiC ok :P
 
8:46 AM
@JoeWatkins it's only about 6 and a half hours by train :P
 
I can think of worse things ... well, only one ... being stabbed in the face ...
 
@JoeWatkins six hours by train is bad?
 
it wouldn't be so bad if it were one train, but you can bet it's four or five ... this is like a nightmare for me, the probability of me managing to get on all those trains is literally nil, I can see that six hours turning into 12 easily, I doubt I would even get to the destination ... easier to stay home ...
 
@JoeWatkins You're coming? :)
 
no :(
 
8:56 AM
oh :(
 
@JoeWatkins is making up excuses :P
 
oh that's not why I'm not going, just can't afford it ...
 
Pretty sure you could get a free pass if you asked for it
 

« first day (1812 days earlier)      last day (3130 days later) »