logs archiveIRC Archive / Freenode / #php / 2015 / October / 15 / 1
dp
if I have a regex like (?:([^{]*?)({.*?}))+, why does preg_match only store the last match in the "matches" parameter?
wfq
hi all
Sammitch
dp: because it sounds like you're expecting it to be preg_match_all()?
or you should change your non-capturing group to capture and vice versa?
biberu
perhaps show some data and expected output?
dp
Okay; for some reason, I missed the options to preg_match_all. It was returning things in a strange order. Related to that, then... is there a way to make preg_match_all *not* return the text that matched the full pattern?
garrettw
I'm looking for a code review from someone very good at OOP
https://github.com/garrettw/noair
carcrash
in a standard foreach($var_array as $var_element){...} loop, is there any garuntee of order? will the elements be itterated over in the same order every time?
Literphor
garrettw, How much are you willing to pay?
garrettw
lol why do you ask?
it's a small lib
         

Literphor
garrettw, I assumed there'd be compensation...time is money, right?
skinux
Can anyone tell me where in PHP source code I would look to see the code that actually scans through PHP source to interpet it?
Sammitch
carcrash: elements will be iterated over in the order they occur, which is not neccessarily related to the ordering of their keys
eg: asort() and uasort() can do fun things
garrettw
Literphor, i do believe people come here all the time looking for free help with their php problems, and it is usually given. so I guess just move along
Sammitch
but simply foreach([foo, bar, baz] as $item) {} will iterate exactly as you'd expect
Literphor
garrettw, Sure but not free work
Sammitch
[ 1 => 'one', 0 => 'zero', 3 => 'three', 2 => 'two' ] will iterate in the defined order in foreach
garrettw
help, work.. the difference is nominal
i'm not asking someone to write me an entire class
Sammitch
skinux: http://php.net/manual/en/function.token-get-all.php will preparse code for you, so that's a starting point one way or another
wfq
all, what would suggest it is the best way to get your user's country where they are connecting for by using PHP?
Sammitch
wfq: ask the user
wfq
I was wondering about getting the IP and quieryig a third-party service
Sammitch
skinux
I'm not talking about API, I'm talking about PHP Interpreter source code.
Literphor
garrettw, Heh we should all hire helpers instead of employees then. It's the same amount of effort for free! :D
wfq
Sammitch. Thanks I checked that. Wonder if PHP GeoIP would be a good candidate too. Never done anything like it
Sammitch
skinux: and the source for that function should point you in the right direction :P
garrettw
whatever
Sammitch
garrettw
Sammitch, I actually already tried posting there, but they make you put the code inline in your post, which for a multi-file lib that's hundreds of lines, it doesn't really make sense
         

Sammitch
you want someone to review several hundred lines of code for free? I'm with Literphor on this one.
garrettw
well thankfully some kind soul in #phpc took a quick look over it and gave me some pointers
took him 5 minutes to come up with a tip for me
i'm trying to learn here
Literphor
garrettw, Then maybe that's a symptom to take a look at. Your code should be modular, it shouldn't be difficult to share and review small snippets of code, one at a time and so should be easy to share
garrettw, If in order to understand 1 class you need knowledge of 10 other classes, maybe that's a symptom your code is highly coupled
xupicor
to be fair though, Literphor, when... you know what - I take that back, I won't be the devil's advocate. :P
no this time
Sammitch
Literphor: I'm just too lazy to read that much code without monetary incentive. :P
xupicor
somebody said "money"?
(Action) sniffs around
garrettw
Literphor, I know what you're saying but no it's not highly coupled... the code just isn't quite as self-documenting as I'd like it to be
Literphor
Sammitch, Perfectly reason I think. I wouldn't have asked for much :p
s/reason/reasonable
garrettw
its open source aka i have no money lol
omfgitsasalmon
Anyone can help me with setting up xdebug for remote debugging? It doesn't seem to work for me :(
queuetip
fishing for php oop ideas, i have to generate 6 xml files that are all only slightly different, with the idea that in the future there could be more slightly different xml files. my first idea was to just create the xml files as templates and use simplexml to overwrite them. maybe a factory with a common interface to load the right files and write the right data?
Literphor
xupicor, It's not always a symptom, that's why I said maybe :p but I think it's likely
zechariah
Hey guys, I have a custom sessionhandler that utilizes a database; and it seems like on ajax-intensive applications, my sessions seem to clear/cache out.. If you guys were facing something similar, where would you start looking? Maybe in the row locking or something? ( here is session class: http://pastie.org/private/sm5ahsehsn3djd0cwo1sda )
my sessions seem to get destroyed(sorry, cache is terrible word to use there :D )
netameta
SyntaxTerrorCat: didnt they removed <?= $entry['description']; ?> ? you have that in your link
xupicor
Literphor: ;)
Literphor
zechariah, Something somewhere is probably calling `destroy` on your session handler or your not validating your sessions correcting against your database
zechariah, Maybe throw a log into your `destroy` method to see if it's called at some unexpected time
zechariah
it's intermittent; meaning it seemingly works, unless it has a heavy dose of ajax (or any request, i'm assuming)
roger
oh, yeah okay :D that's a nice idea hehe
Thanks for the tip :o)
Literphor
zechariah, Throw it into a debugger, but the entire calss can be improved upon such as following SOLID (Specifically single use responsibility) and NOT echoing html
zechariah
I'm pretty sure it strictly works with sessions, unless an exception is caught, which it has some basic debugging information; and fixes the issue at hand
but definitely noted, and could pass the exception logic to another class
thank you very much for your review, and thought on the logger, I really appreciate the tip :o)
Literphor
zechariah, YW
zechariah
@ Literphor actually, to be super clear, I appreciate the critique, and will definitely be re-reviewing to continue decoupling :o) -- I re-read and it seemed dismissive up there, but certainly not intention hehe.
Literphor
zechariah, Meh you can dismiss my advice, it doesn't bother me none :p.
zechariah
Good advice is good advice ^_^
shudon
hi all :) XSL question: is there a named template i can apply to serialize the current DOM Node? maybe even serialize it to pretty colored HTML?
a PHP function would also work
in which case this just becomes an XML question :)
jokke
hi
i'm trying to install dependencies with composer
but i'm gettig an error that the iconv extension isn't installed
Literphor
shudon, If by serialize you made JSON it's possible to convert an XML object to JSON and stringify. If by serialize you just mean a string then you can reference the parent node and access .innerHTML
jokke
it is though
Literphor
*you mean JSON
jokke
and it also shows up in php -m
what could be the problem?
shudon
Literphor: nope :) i have an XML document, and I just wanted to see parts of it as XML.
jokke
- sabre/dav 2.1.3 requires ext-iconv * -> the requested PHP extension iconv is missing from your system.
and there's /usr/lib/php/modules/iconv.so
as well as extension=iconv.so in my php.ini
and like i said it's listed in php -m
garrettw
i have a general question for anyone: what would you say is an appropriate use case for object typechecking, and what isn't?
Literphor
shudon, Ahh XSL is an actual thing. Never heard of it before. Well being XML you can use PHP's DOM http://php.net/manual/en/book.dom.php
shudon
Literphor: indeed i am :) but i don't know if there's a function to pretty-print the XML. i guess i'll try your link
brb
Literphor
shudon, pretty-print? You can beautify, https://pear.php.net/manual/en/package.xml.xml-beautifier.php which will indent/linebreak. If you want syntax-highlighting when displaying in a browser you can use a code editor like https://codemirror.net/. I have no idea about the quality of either
jokke
anyone? :/
Literphor
jokke
yeah i just figured it out
had to call composer with php $(which composer)
Sammitch
composer has it's own ini? dafuq?
Literphor
Sammitch, I dunno, that does seems really weird...but then the same guy answered his own question, maybe it's inaccurate. I wish I was at home to check.
jokke, How come you're running it from PHP?
jokke
Literphor: because apparently that's how it works
Literphor: maybe you can help me out. this seems to be a symphony app
« prev 1 2 3 4 next »