« first day (265 days earlier)      last day (4698 days later) » 
04:00 - 14:0014:00 - 00:00

4:47 AM
hi all
 
4:58 AM
hello!
 
I actually know what I wanted.
How and why does learning PHP make me a better web developer.
 
5:19 AM
@raynos most of the sites these days are built with php and mysql... so you can excel in web development by learning php
 
I can excel in web maintenance ;)
There are solid arguments for using all kinds of web development stacks and all kinds of databases
I can excel in web development without using PHP
 
6:15 AM
@raynos sure you can excel in web development without using php... there are many other tools and languages used in web development, other than php... like python and asp
 
6:33 AM
anyone any experience converting ESRI shape files to KML?
 
6:48 AM
@junke1990 sure, but the issue is converting the coordinates.
 
7:21 AM
@Raynos it wont. No language will. You will become a better webdeveloper by learning the concepts, not the associated languages.
 
@Gordon rephrase that in a self-contained sentence and i'm starring it. i HAVE to.
 
:)
im old and dont need the stars :D
9
 
everybody likes stars :D
come to think of it: this is probably my last week as a PHP dev, at least for a while. i'm starting work with C# soon
 
@Raynos you have been asking the "why should i learn php" for almost a month , and now it seems more and more like trolling
 
had any experiences worth sharing, especially concerning the differences?
@teresko for once, i believe you're right
i mean, if you need others to give you a reason to learn a new language, you probably picked the wrong career Oo (or doing it on purpose.)
 
7:40 AM
@teresko well, i asked @raynos to make up his mind what hes looking for in a language. now he did so the question is fair enough. but yes, we should be through with the topic now because what he is looking for in a language is not what php will give him.
 
8:06 AM
Guys, I need to connect to a device using sockets, the sample code for PHP uses fsockopen - but I've noticed that there is a list of socket functions. Which should I use? Any caveats?
 
morning
 
morning :)
 
@rickchristie dunno the difference beyond whats stated in php.net/manual/en/intro.sockets.php
 
connect just to get stuff or two way communication
 
and thats rather vague to me either
 
8:10 AM
connect to send SOAP headers and XML, and receive response
 
so a soap request that isn't a real soap request (or well, testing or something)
 
kind of
 
@rickchristie why cant you use the SOAP extension then?
 
I'd check if "file_get_contents + stream_context_create" is able to do the job. It usually is
 
@Gordon - I am also considering it.
 
8:13 AM
if it's a real soap server the build in SoapClient should work well for pretty much any usecase
 
I'm new in SOAP, so I don't know if this fingerprint device provides a real soap server or not. I'm going to try to connect with the SoapClient. Thanks for the input!
 
2
Q: PHPunit ignores Exceptions in the setup method

Pim JagerI noticed that PHPUnit ignores exceptions thrown in the setup() method, and simply runs tests even when the setup function throws an exception. In the below code the exception will be ignored, the code below it will not run, and the test_method will fail because it is using an undefined variable....

Anything i missed? :/
 
Good Morning
Regex to search only in that kind of tags <h3 class="tf_search_item_title tf_title_doubleline"> ?
 
8:29 AM
Use an html parser
This one for instance : simplehtmldom.sourceforge.net
 
No I need to do it with regex :D
 
@greg0ire simplehtmldom is crap
@Jasiufila no you dont
115
A: Best methods to parse HTML with PHP

GordonI prefer using one of the native XML extensions, like DOM or XMLReader. If you prefer a 3rd party lib, I'd suggest not to use SimpleHtmlDom, but a lib that actually uses DOM/libxml underneath instead of String Parsing: phpQuery, Zend_Dom, QueryPath, FluentDom or fDOMDocument You c...

 
There i was thinking about how i could communicate that i don't think much of using simplehtmldom at all and gordon cut to chase a lot quicker -_-
 
@Jasiufila regex can parse html but they are unreliable. If you know your markup isnt going to change, you can get away with regex, but if it changes, your regex will likely break. parsing html is a solved problem. there is parsers for that readily available.
 
@Gordon because it doesn't use libxml?
 
8:33 AM
I know that but my task is to do it with regex
<h3(?=[^>]*class="\tf_search_item_title.*?tf_title_doubleline\")[^>]*>
 
@Gordon Or did you have a bad experience with it?
I have little experience in this domain, I only used SimpleXML once to parse html
 
@greg0ire not being based on libxml makes it much slower. and besides that, its almost impossible to extend properly. the codebase is horrible.
 
@Jasiufila you just want to find the tag? (not the content, or whole element)
 
this works
but I've got two kind of tags
 
@Jasiufila then go complain about the task.
 
8:35 AM
@Jasiufila so it doesn't work. :)
 
one with only tfsearch_item_title
 
@Gordon Interesting, I think you already told me about simplehtmldom being crap some months ago, but I didn't remember and certainly won't until I have to parse html myself :P
 
and the next one is with tf_search_item_title tf_title_doubleline
I need to search only in this kind of tags
 
Why do you need to use regex?
 
@greg0ire usually people pick simplehtmldom because a) its called simple and b) because it can do css selectors, but there is 3rd party libs based on libxml that can do the same. Zend_Dom for example or phpquery
 
8:37 AM
Because the parser is build this way, uses regexes to parse sites
 
@Jasiufila heh, good luck with that
 
@greg0ire from my experience there is no gain in using anything else than DomDocument, any solution that is build on simpleXml tends to reach a point where simpleXml is too simple (well casting xml to an array just doesn't work at all) and now you are stuck with a big unmainable array logic instead of nice xpath expressions.
The only php thing i kinda like is fluentDom fluentdom.github.com
 
@Jasiufila again: parsing HTML is a solved problem. You dont need to write your own parser with Regex. It's unreliable. Whoever wrote that parser had no clue. Go and rewrite that parser with a libxml based parser.
 
SimpleXML leads to unmainable array logic?
 
Hey what do you mean Is it impossible?
 
8:39 AM
@Jasiufila we cannot answer that question for an undefined "it"
 
@edorian FluentDom. I'll try to remember this one...
 
@salathe Ok let me rephrase:
 
@greg0ire you dont have to. just bookmark my answer ;)
 
@greg0ire the code looks kinda nice: fluentdom.github.com/docs/index.html Still: using a 3rd party lib usually isn't needed imho ;)
 
@Gordon Already did that a long time ago :P
 
8:43 AM
@salathe I know that php mostly is array-based / hash map based programming. But creating 3 to 5 to infinity dimensional arrays out of xml structures usually leads to devs building really fucked up data structures and than thinking about how they can collapse / traverse their 5d array into a 3d array with combined parameters where having a real dom document would offer one the option to just create one xpath that does all the work
 
@edorian Yeah, it's cool if you're familiar with xpath and the fluent interface makes it enjoyable too
 
@edorian what's that got to do with SimpleXML?
 
@Jasiufila learn XPath. XPath is like Regex or SQL for HTML.
 
@salathe Well when i think "simplexml" i think $x->item[3]->reference->author->name, i know thats not the full scope but from so questions that pretty much everything people use from it
If I'm completly off on that one please correct me :)
 
@edorian because thats about the only thing it's good for ;)
if you like implicit APIs that is
 
8:50 AM
morning
 
morning
 
@Gordon you're not so old :-P
 
@edorian $x->item(3)->getElementsByTagName("reference")->item(0)->getElementsByTagName("author")->item(0)->getElementsByTagName("name")->item(0) yep, DOM is so much prettier
 
what's up?
dom vs. simplexml?
 
@KamilTomšík ive recently started to do some sports again and I can tell while im only 34 i feel like 68. all that php coding has aged me rapidly
 
8:52 AM
you know - by sporting to the grave :-D
 
at least it doesn't break with undefined property warnings ;) And well. /item[3]/reference/author/@name (or whatever the xpath is) at least ether returns something or doesn't.
 
@Gordon, Yes I know this method is better, but the task is to do it with regexes. Thread closed :)
 
@Gordon don't blame php ;)
 
(Having seen stuff like if(isset($x->item[3]) && isset($x->item[3]->reference) && (....)) )
@KamilTomšík just me bickering a little
 
the DOM version would break just as badly
 
8:53 AM
@edorian +1 when I'm dealing with dom/simplexml, I always use xpath, even if it could be slower.
 
@salathe congrats for breaking the layout! :D
 
@Unique_Key get a better browser :)
 
he didn't for me
 
i'm using firefox, foo' :P
 
@Unique_Key get a better browser :)
 
8:54 AM
:|
hah
 
isnt that rather a screen resolution issue than a browser issue?
 
no prob @edorian :P
 
he broke it for me too
 
"Broken" is a relative term.
 
still looking good on 640x480
 
8:56 AM
true enough, i'm using one of those old-ass 1280x1024 panels
 
Guys, is it normal if a soap response doesn't include stuffs like xml version and soap envelope?
 
@edorian get a real screen :D
 
I got the response as was written in the manual though
 
@UniqueKey I pressed the "small screen" button
 
@rickchristie it's not soap without a soap envelope
 
8:57 AM
Chrome puts a line-break "getElementsByTagName("author")-"<-there for my screen resolution.
 
fair enough
 
I'm rather happy with my 3 24'' montiors, thanks :)
 
Firefox just continues the line.
 
hehe
 
@Aether yeah, there is "a little broken", "pretty broken" and fu*ked up beyond repair or as a euphemism "IE6 quality"
 
8:58 AM
@rickchristie When calling ->getLastRespone or just when calling a function?
 
(Morning)
 
i'm curious, though: who's maintaining the webchat?
yo @Robik
 
The SO/SE people themself afaik
 
@edorian you are running your 24" screens on 640x480?
 
kicking it old-school, i guess
 
8:58 AM
@Gordon Sadface for those who have to keep compatibility with IE6.
 
Hi @UniqueKey
 
@edorian - pastebin.com/DLQJLakX - with SoapClient::__doRequest()
 
@Gordon "resize browser window to 'list of resolutions i check against when looking at our webpage'
 
> still looking good on 640x480
> I'm rather happy with my 3 24'' montiors, thanks :)
@Aether yeah, sadface for me :)
 
@rickchristie any reason you call __doRequest directly?
 
9:00 AM
@edorian - first time using anything related to SOAP, expect some facepalm moments
Should I extend it?
 
$client = new SoapClient("some.wsdl");
$client->method($parameter);
 
the manual doesn't specify wsdl to download, I searched for 'wsdl' at the pdf and no results
 
i would assume that "http://192.168.1.241/iWsService" returns a wsdl
just guessing though
 
@edorian that should use __soapCall rather than ->method
 
so thats fine too
What I'm getting at: you can just call the methods the service offers on the soap object
> This is a low level API function that is used to make a SOAP call. Usually, in WSDL mode, SOAP functions can be called as methods of the SoapClient object. This method is useful in non-WSDL mode when soapaction is unknown, uri differs from the default or when sending and/or receiving SOAP Headers.
@salathe yeah, thanks
 
9:06 AM
Semantics Check: can you point out the difference between iterates over several iterators one after the other and iterates over multiple collections. People who know those Iterators may not answer.
 
192.168.1.241/iWsService returns 'XML Parsing error: no element found' - empty response
 
@Gordon "People who know those Iterators may not answer." aww :(
 
maybe it's not a soap server, but just something hacked together to resemble one
 
@salathe actually, it makes sense if you know the iterators, but for someone who has never used them before i find those descriptions not sufficient to understand the difference.
thinking about writing a blog post illustrating the difference
 
@Gordon it doesn't help that the descriptions are swapped in the docs :P
 
9:09 AM
@salathe which proves my point ;)
 
@Gordon Nope, can't
 
@edorian you want me to blog about it?
 
Given that i don't know what a "PHP-Collection" is
I guess i don't. Or rather: I'm not going to in the next few weeks
 
@salathe speaking of the docs. Did they decide on anything yesterday? Will __autoload be deprecated or ext/mysql?
 
@Gordon no to both, though we may put more references to mysqli/pdo in the docs for ext/mysql and strongly point people towards spl_autoload_register for __autoload.
 
9:14 AM
Thanks for the help @salathe @edorian
gtg, german class
 
"Viel Spass"
 
@edorian its spelled Spaß, isnt it? With a "Ligatur".
 
@Gordon The thing i really hate about german is that my default argument "get of my back I'm not a native speaker and doing the best i can" doesn't work. I have no clue
 
@Gordon I just fixed those multiple/append iterator descriptions :)
 
9:17 AM
But you're right
 
@salathe I'm gonna write some examples in my blog post. Can add them to the docs later
or to the spl wiki
your pick
 
depends on the contents of the examples, I'll have a look when you've blogged :)
 
9:42 AM
@salathe interesting. Is that expected behavior: codepad.org/VKVy52zH
 
@Gordon yep -- the keys overlap (foreach over and have a look)
 
i would have expected it to return the contents of the all the appended iterators instead of merging the arrays
 
@Gordon set the 2nd argument for iterator_to_array to false :)
 
@salathe that does nothing
it will only include all the elements when i change the keys in one of the arrays
 
@Gordon sure it does - codepad.org/IG2Aaa7e
 
9:46 AM
err
my fault
i put the false after the iterator_to_array call
thanks
 
hehe, easy mistake to make :)
 
morning
 
Hello @nikic
 
*looks at the example* I'm confused. "use_keys => Whether to use the iterator element keys as index."
How does that lead to the expected output
 
interesting though that setting use_keys to true will do n+…+1 instead of 1+…+n
e.g. it adds the array in reverse order
 
10:03 AM
so it's use keys because of [0][1] and so on
i see, that kinda makes sense i guess
sort of.. i think i just assumed iterator to array would do the same thing as foreach, no matter the situation
 
Now that you come to speak of array_merge and +, what is your preferred way to set defaults in an array?
I.e. do you write $options = array_merge($defaults, $options)
or $options += $defaults
 
somewhat different results though when there is assoc keys in the arrays: codepad.org/pexVMQ3H
 
@Gordon huh?
 
@salathe just trying to find out the differences
 
my huh was directed at "it adds the array in reverse order"
 
10:13 AM
@salathe yeah, i was probably drawing false conclusion looking at it
iterator_to_array really does this, does it?
$array = array();
foreach ($appendIterator as $key => $val) {
    $array[$key] = $val;
}
 
@Gordon basically, yes
 
What is iterator_to_array actually good for? For serializing iterators?
 
function iterator_to_array($iterator, $use_keys = true)
{
    $array = array();
    foreach ($appendIterator as $key => $val) {
        if ($use_keys) {
            $array[$key] = $val;
        } else {
            $array[] = $val;
        }
    }
    return $array;
}
this is what it does.
at least thats producing the same results as in my example
 
@Gordon yes, that's essentially all that happens
 
"What is iterator_to_array actually good for? For serializing iterators?" ?
 
10:24 AM
@nikic I'm hoping Gordon's blog post will answer that question, too.
 
@nikic for turning iterators to array
 
@Gordon Wow, would have never thought it does that. (The question was more: Why would one want that?)
 
Ah, right - for objects that implement Iterator or IteratorAggregate?
 
@nikic eih, not all php functions really do what they claim they do ;)
 
@nikic in_array("tinkles", iterator_to_array($kittens))
 
10:27 AM
One application I could imagine is for caching iterators in APC. E.g. a PDOStatement. (Though here I would prefer $stmt->fetchAll() instead of iterator_to_array($stmt))
@salathe nah, that feels inefficient ^^ I would do a foreach ($kittens as $kitten) if ('tinkles' === $kittens) return true; return false; for that.
@Gordon I could well believe that. But do you have an example of a misbehaver?
 
@nikic just showing where you'd need an array, that's all the function is for.
 
@nikic tbh no. cant think one any, right now
 
@salathe :) array functions should just learn to handle iterators :P
 
@nikic heh, really no they shouldn't :)
 
iterator_apply maybe.. that doesnt do what it says
 
10:34 AM
@Gordon Why? It does apply a callback function to every element of an iterator :)
 
Call a function for every element in an iterator
thats a huge difference, because actually, none of the items in the iterator get passed to the callback
 
hm
you are right, right you are
 
i mean, it does say for in the docs, but its not what i'd expect it to do from the function name
 
additinally those functions should all really be named traversable_to_array, ... (I do hope they work not only on Iterators but on IteratorAggregates too, don't they?)
@Gordon Yeah, that function feels kinda pointless ^^
 
Iterator and IteratorAggregate are not the same as Traversable, are they? Not sure right now.
 
10:39 AM
together they are ;)
both are instanceof Traversable
Traversable is the generalization of Iterator + IteratorAggregate ;)
 
ah i see. wasnt sure of that anymore
 
you can have Traversable without Iterator and IteratorAggregate, but it's just a marker interface
 
but im not sure iterator_to_array work with just a Traversable
 
@Gordon Shouldn't this print out multiple lines if it's being called for each element of $appendIterator?
 
@Aether No, he didn't return &true; ;)
 
10:42 AM
@Gordon you can
 
@Aether was just to show that it doesnt pass in the iterated values
 
I mean, it does work with (just) Traversable's
 
@Artefacto ok
 
@Artefacto But you can't implement Traversable from userland code and I do hope that any core code that implements Traversable is indeed traversable ...
 
@nikic I'm not sure I understand that.
 
10:43 AM
@Aether If you want iterator_apply to continue iterating the callback function must return true ;)
 
@nikic I did not know that.
Thanks for the clarification.
 
can we have iterator_map that does the same as array_map?
even if its just a convenient shortcut for array_map('cb', iterator_to_array($iterator))
it just feels wrong having to convert the iterator to array just to be able to call a callback for every element in it
 
So perhaps you'd prefer some sort of CallbackIterator
 
:D
 
10:48 AM
right, i remember we have that in trunk
 
we do? How does it work?
 
(Recursive)CallbackFilterIterator added to PHP trunk - http://bit.ly/dJvZaG
 
I was under the impression it didn't transform the keys/values, only used a callback to decide whether to filter or not
 
SPL iterators are nice :)
 
10:52 AM
@Artefacto i havent looked at it too closely so you might be right
in fact you are
its a filteriterator
 
@Gordon the clue is in the name :)
 
@salathe yeah.. need more coffee
 
well, i hope that one day (5.5. maybe) everything /most _array_ will also work with iterators anyways (or well, with a traversable if you want)
so that in_array would just work without the array casting
 
@edorian urgh, I'd fight against that for sure!
again the clue is in the name!
 
im not sure i want a callbackIterator then. I'd rather like a map() method on the Iterator interface but that will break BC in userland iterators so iterator_map please
 
11:02 AM
not all iterators are necessarily writable like that
 
@Gordon But iterator_map will return an array then, or what?
Cause you can't iterate an iterator by reference
 
@salathe I worded that badly, i don't want to necessarily change the implementation of in_array. But if their should every be a \PHP namespace than stuff like that should just work, maybe in_array isn't the best name then, yeah. But in_traversable or in_iterator isn't all that nice. So what the hell do i know
 
@nikic good point.
 
Found something: gist.github.com/1071613
 
@nikic how did you find that?
 
11:15 AM
yeah, its kinda like iterator_to_array_by_callback
 
@salathe I'm following you on github ^^
That commit seems strange
seems like the commiter forgot the actual change
 
@nikic looks like they missed a file on the PHP_5_3 branch
poke Felipe on IRC :)
 
11:45 AM
hi
@Neal: ytou know amzon check out
 
12:39 PM
@edorian what about "includes/included"?
 
I have question about session
if i have a file in ../../../dir/dir/file.php and inside this it starts session and sets some variables, then if i start session in the current file will it still get the ses vars?
 
doesn't matter where file is located
but does matter where php takes the session_id and what session_id value is
 
example:
me.php - session_start(); echo $_SESSION['test'];
../../../dir/dir/file.php session_start() $_SESSION['test'] = 123;
 
again: doesn't matter where script is located
 
hmm
hey!!
just checked they have different session_ids
rbrfp4bdm1sedrh50qbojei1e1
pkpjgn2u1b050tojd5odomt2i4
is that why i cant get the vars?
 
12:44 PM
sure
 
But!!
Ok i found the fault..
when flash works with php it stars new session
 
:-S
 
0
Q: Working with SWFUpload and PHP sessions issue

KaremI am using the jquery addon swfupload. This addon, SWFUpload works with the php file upload.php (sends the uploaded file info to it and the php saves to dir). Now my issue is that in every page on my site i have included page_protect(); This starts sessions checks and sets session variables ...

 
I cannot belive swfupload can cause any session issues
 
When it execute through the swfupload it makes new session
When i do it with the html form and execute upload.php it uses current session and works fine!
 
12:52 PM
Have you looked at http requests?
why actually it "starts new session"?
what actually causes that?
 
I just found out it sends the phpssid
 
uhm, it sends it in get parameters?!
what value does it send?
 
Ah so the flash does nothing !!
It sends the session_id()
and the session_id() there is a new one
how can it be new one?
so its nothing about the form i found out now
or the flash
 
:-S
 
post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
 
12:54 PM
flash knows nothing about session_id php function
why do you pass it explicitly? what's about cookies?
 
wait..
 
if it sends the value from html generated by php - then session id IS ALREADY changed
and flash just does what you asked it to send
 
yes i can see that now
 
flash has its own session, that's just the way how it is...
 
ok i need help
I now know it pass the right session id
But still in upload.php when i do session_start() then echo session_id i get another new session_id
with is not the current
 
1:05 PM
so - debug where it gets (if it does) that wrong session_id
 
it gets it in the upload.php
thats the only thing i know
 
it get's it from where?
 
Even if i pass the current and right session_id in the post_params it still shows me a new one in upload.php
 
well, you don't pass it correctly then
 
maybe i should grab that $_POST["PHPSESSID"] and change the session
 
1:07 PM
nope
you just need to do that in right way
and your php will be happy
 
right way.. :D
hmm
i had the same problem whole yesterday too..
but now i feel closer to problem
and more unpatient..
how do i pass it correctly ??!
and why should i even pass the session id
From what i know in php i should not pass any session i should just do session_start() ..
right?..
I can see in the samples upload.php they have done:
// Code for Session Cookie workaround
	if (isset($_POST["PHPSESSID"])) {
		session_id($_POST["PHPSESSID"]);
	} else if (isset($_GET["PHPSESSID"])) {
		session_id($_GET["PHPSESSID"]);
	}
why would they have done that?
does that set the session_id?
 
@Karem it's called session injection - you want to ignore cookie and receive that session id from post, which means you can share flash session with page session
@Karem however receiving from GET is not a good idea... actually even POST is not a good idea, it should be at least signed somehow...
maybe @ircmaxell could give you more security-related info...
 
@KamilTomšík: what is the significant difference between post and cookie?
both are just a part of request
 
@zerkms flash will send cookie - with its own session id - and you want to ignore this session, you want that request to be processed in page session, so you have to pass proper session id somehow
 
i am write ...

flashMsg("hello"); in controller but it doesn,t display message,

i wont to display the flsh meaage like after login the messge will be displayed "Success fully login".... this same effect i wont to use without any extra js and css.
 
1:22 PM
@KamilTomšík: i've asked about security aspect
from security point of view - they are just a parts of a request
none of them are more or less secured
 
hey kamil can you help me??
i am write ...

flashMsg("hello"); in controller but it doesn,t display message,

i wont to display the flsh meaage like after login the messge will be displayed "Success fully login".... this same effect i wont to use without any extra js and css.
 
@zerkms you can't spoof cookie by form. you probably can use xmlhttprequest, however I'm talking about session hijacking - when you'll receive url, or click the form, which will take you somewhere, where you will login... nothing bad will happen, but attacker now knows session_id, so he can just login using cookie in his browser
 
1:39 PM
@KamilTomšík: protection from session hijacking is easy enough
 
posted on July 08, 2011 by Henri Bergius

As I've written before, I'm concerned about the state of the PHP ecosystem. There are lots of good applications written in the language, but there is very little code sharing between different projects, mainly because of framework incompatibilities, but also because of quite a strong NIH culture. But there are also bright points. I've recently seen lots of exchange of ideas, and even potenti

 
1:56 PM
@KamilTomšík aha okay, sorry for being afk
@KamilTomšík
when I have this:
if (isset($_POST["PHPSESSID"])) {
session_id($_POST["PHPSESSID"]);
} else if (isset($_GET["PHPSESSID"])) {
session_id($_GET["PHPSESSID"]);
}
@KamilTomšík
it changed the session id to the current and right one, but still i cannot get any of the variables to output
If i remove it i get another session id
Before the upload:
session_start();
echo session_id();
$_SESSION['lol'] = 123;
echo "<br>".$_SESSION["lol"];
outputs:
jatsvlvac4qeiirh4b695ep654
123
 
04:00 - 14:0014:00 - 00:00

« first day (265 days earlier)      last day (4698 days later) »