« first day (3753 days earlier)      last day (1177 days later) » 

12:43 AM
SplFixedArray writes to invalid memory if an element destructor calls setSize ・ SPL related ・ #80663
 
 
8 hours later…
8:15 AM
morns
thanks for keeping the room alive @Jeeves :)
 
 
2 hours later…
10:33 AM
Ajahha
morns
 
 
2 hours later…
12:14 PM
Good morning everyone. I have a question to make a GET request in Crul is just that?
$curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, "http://url/abc/list?placa={$rowV['aaa']}&renavam={$rowV['bbb']}");
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

        $response_body = curl_exec($curl);
        $err = curl_error($curl);
        curl_close($curl);
 
@Sjon Tyson coincidentally created an enum demo himself so unless you're working on something we can also share that in the ML. tysonandre.github.io/php-rfc-demo/enums
 
 
2 hours later…
2:16 PM
@Tiago I would never write such code, but yeah it should work. However, please learn PHP best practices when you get the chance.
 
2:57 PM
@Dharman Thank you very much for your feedback, would it be possible to inform what is the best practice to consume a json return?
 
3:33 PM
@Tiago If you want to make it easier then just use Guzzle
 
@Dharman OK
 
 
2 hours later…
5:22 PM
I moved my clock one month into the feature and OPCache wouldn't recompile my PHP files again. Why?
 
s/feature/future?
 
yes
autocorrect
 
5:46 PM
seems like autocorrect is aware that there is no future ;P
 
not with that attitude ;)
 
6:17 PM
In Symfony, How can you access an entity's relationship from within a service? for some reason it's returning an empty array.
 
@NikiC Do you by chance know what is the proper way to optionally use a symbol from another extension (i.e. depending on whether the ext is present or not), while supporting both the extensions being dynamically or statically loaded?
i.e. all of (my extension is built statically, my extension is loaded dynamically) x (other ext is built statically, other ext is loaded dynamically, other ext is not loaded at all)
Or maybe know where this is already being supported so that i can copy-paste the logic from there :-D
 
@bwoebi got a code example?
 
6:57 PM
@KerrialBeckettNewham github.com/bwoebi/php-uv/commit/… I attempted something, but apparently still segfaults for others
so … that wasn't it … hence I'm looking for whether a proper solution exists
 
7:27 PM
What's a suitable name for something that provides implementations based on some lookup? Factory doesn't seem right, as it doesn't provide new instances. Registry maybe?
 
@kelunik Provider? ServiceLocator? And I will ping you if I find the really good naming resource I was looking for....I distinctly remember seeing one a mere eight years or so ago, but it seems to have vanished. Pretty sure it was on a Java related site, and they are all dissappearing from the net.
 
@Danack Thanks! Specifically, it's looking up a type handler by type to handle database rows and converting the assoc array to an object / converting the result iterator to another collection type, e.g. an array.
 
@Danack Please update me as well(or just pin it here) when you find it, I saw your tweet about it for Marco and I am very interested in something like this as well.
Thanks
 
I put a few interesting links in en.reddit.com/r/PHP/comments/l03eio/… - but I am 90% sure there was a really great page that had a about 100-200 different verbs for method names .....somewhere.
 
@bwoebi I'd guess a combination of HAVE_ check and dlsym would work, but can't say I ever tried
Ah, I see that that's what you're already doing ^^
 
7:46 PM
got back to php since 10 years ago, i was wondering if there is a nice "common purpose" library to manipulate arrays and other structures, you know the kind of library that "everybody includes"
 
@Danack Thanks, I will check those links.
 
@ManuelOdendahl not really....most of the time it's not needed. About the only one that I know of is Laravel collections which I've heard good things about, but don't personally use.
 
cool, thx
 
Hello
 
8:03 PM
Is it me you're looking for?
 
Yes. How did you know?
 
it was something in your eyes.
@kelunik registry seems fine. The only other ones I can think of are builder or maybe TypeAdaptor seems to be a thing used in GSON
 
8:40 PM
Wait a minute, cups don't have eyes..... I'm on to you.
 
8:57 PM
@CupOfJava cough
 
Ik :P
 
@NikiC yeah and I probably fucked that up somehow
@kelunik no missed that one :-/
 
9:53 PM
DateTime::add() behaves incorrectly at DST transition ・ Date/time related ・ #80664
 
10:26 PM
^ I bet it doesn't
@CupOfJava they do if you fill them with potatoes
 
@DaveRandom I'll be honest, I put googly eyes on my coffee mug after that conversation. I wanted to see what it would look like.
Has anyone run across the PHP equivalent of this question: stackoverflow.com/questions/15523514/…
 
As I am a gentleman, I will not point out the difficulty you would have had looking at yourself before acquiring the aforementioned eyes
@CupOfJava do you want this at arbitrary depth?
it seems like a weird thing to want tbh, are you sure you don't want xpath instead?
 
....
 
what I mean by that is, why would you know the structure of an object but not the level at which is exists?
it also raises questions like whether you want depth-first or width-first searchiong
 
I have a way to search deep into an array by key and position but its really inefficient and doesn't work in all cases.
 
10:39 PM
"really inefficient" is a dubious statement, this is inherently O(n) and you are looking for an arbitrary piece of data, it's not really possible to be inefficient unless your search is somehow worse than O(n)
though I suspect "depth first" vs "width first" is what you mean by "inefficient"?
i.e. it walks all the way down (or all the way across) meaning that it tends to visit more leaf nodes than needed on average
but the only thing you can do about that would be to flip it, which will make it better in some cases and worse in others
an indexed query tool (like xpath) would probably serve you better
...but obv I say that knowing very little about what you are actually doing
 
Ok, I'm trying to make a crawler that takes something like site.com/path/result and returns site.com => Array([path/] => Array([results] => url)) but when it runs across site.com/results I don't want it to check if "results" is in the array but that results is in the array at two levels in.
I have the return but I also want to be able to match the second url against the first.
 
it sounds to me like you might do better with a flat lookup table with full URLs as the keys?
i.e. it sounds like you are essentially trying to de-duplicate stuff
 
The issue I'm running into is that I'm returning that "result" is in the array (somewhere) but I can't return at what level "result" is on.
yes
 
so rather than walking a multidim structure every time, generate some kind of unique key to use as a lookup in a flat table
i.e. if (isset($visited[$url]))
where $visited is a 1D assoc array with URLs as the key and <any non null value> for URLs you have already visited
or did I miss the point?
 
No, I think we're on the same page
 
10:50 PM
it doesn't necessarily need to be the URL, just some unique (reproducible) string you can use as an array key
and just maintain it as a separate structure for fast lookups
 
Interesting. Would you happen to know any useful links about this?
 
I guess what I am talking about is essentially the same principle as database indices
maintaining a separate lightweight structure alongside your actual data, which exists specifically for referencing and lookup purposes
I have used this general approach for numerous things in the past, let me try and find some codez
@CupOfJava this answer I wrote many years ago is probably not completely useless
I haven't re-read it, but I remember being fairly pleased with it at the time
 
Thank you for the help.
The time it was taking me to achieve what I wanted was unreasonable.
 
no drama, I need to sleep very soon but if you wanna discuss more tomorrow I will be about in the afternoon (UTC)
it sounds like you are doing something I would be interested in :-P
 
That sounds good. Maybe by then, I'll hopefully have something working.
 
11:00 PM
that answer isn't a direct answer btw but it is all about how assoc arrays and RDBMS tables relate to each other, and it has some stuff about indexing
I have to bail as I have to get van into garage early tomorrow
ttyl
 
11:21 PM
gn
 
11:34 PM
I'm sorry but I must do a dummy question :-(.
In foreach loop isn't need to be freed the memory if I create a var inside loop right?. This mechanism how it's implemented, it's correct to think that of each end loop the var lose the reference (refcount goes to 0) when assigned and the memory it's freed ?. And so it's for this that after foreach, last assigned var it's still alive?
 
11:49 PM
@BruceOverflow Rephrase the question, ask one at a time and provide some sample code if possible, if possible.
 
@Tpojka ok
with this code
<?php
$arr = [1, 2, 3, 4, 5];

foreach ($arr as $val)
{
$b = new DateTime();
}

I must unset the $b for each loop, I think no right or not?
 
2084
Q: How does PHP 'foreach' actually work?

DaveRandomLet me prefix this by saying that I know what foreach is, does and how to use it. This question concerns how it works under the bonnet, and I don't want any answers along the lines of "this is how you loop an array with foreach". For a long time I assumed that foreach worked with the array its...

 
@BruceOverflow Each iteration $b will be assigned with what ever is on the right assignment side.
 
@Tiffany yes I read... but I did not found the answer for my doubt
@Tpojka ok, I follow...
 
Same as:

$a = 1;
$a = 2;

// var_dump($a)
 

« first day (3753 days earlier)      last day (1177 days later) »