« first day (1773 days earlier)      last day (3400 days later) » 

08:06
" anonymous functions" "closures" lambdas are all they same
@AnmolRaghuvanshi big projects? Probably custom. Agencies that churn out cheap sites for clients? Probably framework.
@AnmolRaghuvanshi Kind of. It depends on the context. Lambdas are usually more frequent parlance in Mathematics, for example. Closures and anonymous functions are more frequent in programming. Closures, usually - though not always, entail some component of block scoping.
user3119231
$exists = "";
	$empty = "";
	foreach ($columnHeaders as &$columnHeader){

		global $db_host, $db_name, $db_user, $db_pass;
		$db = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8", "$db_user", "$db_pass");
		if (count($db->query("SHOW COLUMNS FROM `tickets` LIKE '".str_replace(" ", "_", $columnHeader)."'")->fetchAll())){
			$exists .= $columnHeader.", "; // result are the headers Ticket, Date,
		}
		else{
			$empty .= $columnHeader.", "; // result is unimportant
		}
		$db = null;
	}
	echo($exists."<br><br>".$empty);
(see full text)
user3119231
anybody has an idea why csv is not imported into database?
@Sherif An anonymous class is a local class without a name.
is it right
08:13
It's a class without a name, sure.
@Patrick means cheap websites are result of framework..
That's just completely ignorant.
Happy Mondays
The framework/tool you use really doesn't say much about the size of your company or its finances.
@salathe Why is there no happy.monday? Who do I write a strongly worded letter about this atrocity?
@Maurize your prepared statements are emulated
also, what's with the global variables ?!?
08:29
Oh wait, happymonday.today is available, phewww
user3119231
globals are fine. Maybe there is an easier way to insert only the csv columns which are in $exists?
I took decision of writing article on 1.)why,why not to use orm,framework already there are some but....
2) closures in php :) hope anyone will review my article
@Sherif also available: monday.fail :)
@salathe hmmm you're giving me ideas
@Sherif if that idea is to buy a bunch of domains, then never do anything with them... go right ahead :P
08:32
Oh yea, you nailed it right there.
But hey, what's the point of a credit card if you never use it
first one will take some time http://chat.stackoverflow.com/transcript/message/25269034#25269034
but not second one
user3119231
or is possible to get cells by column names?
@salathe you own gophp7.org, right?
@Sherif yup
@salathe Oh man, that site's a model of pure genius :D
It used to be a lot more colorful, what happened?
Was it enduing mass seizures?
08:36
heh, apparently php.fail and php.wtf are already registered.
boo
tho I am in the camp thinking if you hate mondays you probably got the wrong job
I used to hate Mondays because it meant that I still had a hangover from Sunday. I don't know why I hate it now. Maybe because I want ot fit in with the cool kids?
@Sherif To find joy in work is to discover the fountain of youth :P
@AnmolRaghuvanshi Is that what the fountain of youth does? I always thought it just made you younger.
08:42
@Sherif Yeah, @Sjon got it. php.wtf ;-)
@kelunik Yea, I guessed as much from the redirect
@salathe Oh yea, that's sexy right there!
Although, now I'm getting dizzy.
@salathe I like the dark purple of gophp7.org a lot more than the header purple of php.net.
user3119231
	global $db_host, $db_name, $db_user, $db_pass;
	$db = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8", "$db_user", "$db_pass");
	$query = "LOAD DATA LOCAL INFILE 'temp/".$_GET['csv']."' INTO TABLE tickets FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' IGNORE 1 LINES(".substr($exists, 0, -2).")";
	$result = $db->query($query);
	echo($query);

	output:
	LOAD DATA LOCAL INFILE 'temp/Commercial part requests from inbox.csv' INTO TABLE tickets FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY ' ' IGNORE 1 LINES(CE Approval)
(see full text)
user3119231
and import does not get executed?
08:49
@kelunik me too, it's the purple of the border between the header and the grey on php.net
moinday
moinday
can you please tell me how can I make REST calls using Java, is there any example for that. Also can you please help me with this post - stackoverflow.com/questions/32170302/…user3181365 14 hours ago
bahahaha
Heh, if you run $("#container").css('background-color', '#4F5B93'); in your javascript consol here it makes the chat a lot more interesting :)
The PHP at the top almost makes it feel like php.net
Or $("#container").css('background-color', '#8892BF'); to go easier on the eyes
@Maurize please stop using global variables
user3119231
08:58
@tereško why?
because they are bad
user3119231
and why? :D
@Maurize they make the code virtually untestable, pollute the namespace, create invisible coupling, make code harder to understand and have no access constraints
09:02
haha..
We need an <insert every other PHP framework in existence here> gif maker with that and we'd be in good shape.
user3119231
@tereško in this case it doesn't matter I think. I use it just for sensitive data.
wow
you obviously didnt even understand what I wrote
@Maurize [star_trek_double_facepalm.gif]
user3119231
@tereško I understand but this isn't the issue.
user3119231
09:05
@Sherif No, we're not just talking about all frameworks here, it was more Laravel specifically
I was
“It’s too bad that stupidity isn’t painful.” ― Anton Szandor LaVey
Me and @FlorianMargaine weren't :)
@Maurize Well, it's an issue. Your immediate issue is that you need to grant file permissions to the database user using LOAD DATA INFILE dev.mysql.com/doc/refman/5.1/en/…
09:07
@DaveRandom You at next month's PHPNW?
@Jimbo Not been for ages, what's on?
Actually I may be away
Not sure
This month we have a talk by James Mallison about "Websockets and Torrents: a match made with PHP"

Websockets are a protocol allowing bi-directional, full-duplex data transfer over a single connection. Learning how to implement real push notifications opens up the world of event-driven programming and what better language to take a look at this technology with than PHP?

This talk involves the story of a mostly legal side project of mine involving torrenting, data transfer and the joys of event-driven programming. Walking away you should have a clearer understanding of websockets, some o
(see full text)
user3119231
@Sherif thanks. Will read this.
user3119231
@tereško yeah, you would scream a lot, huh?
When I try to merge master into the feature branch, git tries to delete all the new files and undo all the new changes in the feature branch. As far as I can tell it was never merged into master though. Any ideas what could cause this?
09:10
@Maurize You know hatred only breeds more hatred. Why not focus your energy on taking the good from what advice people are willing to share and leave the bad so that you can become a better you?
user3119231
@Sherif tereško
@Maurize please stop using global variables

Maurize
Maurize
@tereško why?

tereško
tereško
because they are bad

Maurize
Maurize
and why? :D
user3119231
you kidding me or what?
8 mins ago, by tereško
@Maurize they make the code virtually untestable, pollute the namespace, create invisible coupling, make code harder to understand and have no access constraints
Guys
See... this is why we can't have nice things.
09:11
ehh .. fuck this .. another one for the ignore list
user3119231
I will concentrate read this.
I have read the following: // Define connection as a static variable, to avoid connecting more than once
@Sherif he wrote a tutorial on best practices and well, I was not really sure why "static" and not just the variable
@Demorus No idea, but why don't you try asking the person that wrote it?
@Demorus emm .. that a bad advice which uses static variable to create global state
I doubt Maurize knows what testing, namespaces and coupling are...
09:13
basically, that person is talking about using a singleton, @Demorus
@Maurize please read up on that stuff if you want to be taken serious as a developer
@tereško singleton? I will google this now
@Demorus Me neither. I have no idea what they meant since I never read what you read. I can only guess. Which is why I'd ask the person that wrote it what they meant.
@Demorus it's an anti-pattern
For all I know, in context, they had made a very good point.
@Sherif can you recall, when was the last time you saw static variables used to make good code?
I thought I would ask you guys to double check if that makes sense
@Demorus please don't use that tutorial. It is actively harmful.
@Demorus Ah, OK. In that context it looks like it's a comment in their code where they're using a static local scope to retain the db object.
In a local function scope once the function returns all its variables are unset.
Obviously that's not a great way to retain the object either. A better way would be to pass it into the function as an argument.
@teresko how is it harmful? It is best thing I found so far for starters like me
09:17
I am trying to authenticate a user against LDAP using his password. The encoding of password is utf8 ( as we checked using mb_detect_encoding). We are able to bind user password successfully, even when password contains special characters (e.g. Œ, ¿,¥, ¢) . However When the password contains spanish character i.e Peseta (₧), We are not able to bind with ldap successfully. We wonder if it could be a problem with php ldap function
@Demorus it advises to use global scope and query concatenation
@Sherif I see, how bad would you rate his method from 1-10?
@tereško OP is now bitching in room 17 :D
@Patrick dont you need to commit to the feature branch, checkout master and merge the branch into master?
@Demorus Pretty bad. I'd say it's a 1, but my standards may be very different.
09:18
@MarcelBurkhard We usually merge master into the feature branch. I get the same problems when I do what you describe btw
@tereško Could you please help with encoding
@Sherif in the point of view of a experienced developer? You can say my knowledge and experience is very fresh since I started 3 weeks ago. Is it at least a good starting point? I mean for studying how it is done.
@Tarun honestly, I am not sure. Encoding is a bitch. Try asking the question to the entire room.
@WholeRoom Can anyone help
@Demorus Not really. As a starting point, I'd say it teaches bad habits that are harder to get rid of over time. If you're new you should start by learning about Dependency Injection, instead, which is a much better design pattern and will likely prove more useful for you over time as you progress.
09:20
@Demorus the problem is that what you are learning are bad practices. You cannot build a skyscraper if your first 3 floors are made of shit and snot
@Demorus It's not a good starting point. The main problem is that it does not use prepared statements. Code written like this will likely be subject to SQL injection vulnerabilities
Yea, there's all kinds of fail in that article, honestly.
If you're not afraid of objects, I'd look for a PDO tutorial rather than a mysqli tutorial. Using prepared statements is much simpler in PDO
This might be a good starting point for designing your application from scratch https://github.com/PatrickLouys/no-framework-tutorial
Sadly I haven't found time yet to do a DB chapter. But if you follow that, you only need to define the PDO info in you dependencies file and then depend on PDO like any other class in the tutorial. Then use prepared statements and you should be good to go
I'll try to make time for the tutorial in the next few weeks. Seems like people actually read it so no more excuses... :)
@mysql_select_db($database) or die( "Unable to select database");
how intelligent
09:22
@Patrick No excuse
@AwalGarg that part was the "bad example" in the article
Why do I keep finding security issues in <insert-obvious-framework-name-here/>?
I feel like knowing some security stuff is more of a curse than anything else...
@tereško yeah but some sites actually promote code like that :/
@Ocramius Do they get fixed?
@Ocramius you are just a hater. Stop. Also, looking for security flaws is wrong (I was told so by Oracle seclists.org/isn/2015/Aug/11)
09:24
@NikiC yeah, but I have to report them >.<
@sherif and NikiC can I learn from the tutorial and include prepared statements?
By the way, dependency injection is related to OOP in any way? I stumbled across a site code.tutsplus.com/tutorials/…
@tereško EULA says NO?
So I believe I better start with procedural since I have some trouble with OOP
@Demorus No, DI is not necessarily specific to the paradigm you choose. You could use DI in a functional paradigm just as effectively as you could in a object oriented one.
DI just means you inject your dependencies where they're needed. Rather than trying to create them there.
That's all.
09:28
@Sherif any good tutorial site before I stumble across something bad again?
No, that's a pretty basic thing.
@Demorus no point in learning something bad just to unlearn it later ;)
basically, @Demorus, if you have a function printArticle() the $article and $printer should be passed to it as parameter. Explicitly. That way you can always see what variables are affected by the function. If the $printer was global, you would have no idea, that the function requires it to exist.
There's no such thing. Learning from a single source is what's bad.
A lot of people expect to be able to write production code on their first day of learning. Well PHP has been accommodating to that... Personally I think there is nothing wrong with learning things properly first before you put them to use.
09:31
@teresko so I need to add my $connection variable as a parameter in my functions if they require it?
@Demorus yes.
@Demorus Yes, that's dependency injection right there in a nutshell.
bah, I'll first try it out on some live sites
@Sherif so what if I follow the tutorial and then when I nailed it I will modify it to include prepared statements and dependency injection?
@Ocramius Hey, that's what Obama Care said!
09:33
Really, this sort of shit makes me angry as heck. Rookie mistakes. BAH.
I'm just angered by the incompetence.
@Demorus Well then you'd have successfully succeeded at failing in order to go back and succeed at learning, I suppose.
But really, hearing you guys makes ,me a scared believer that over 60% of the tutorial sites are rubbish
@Demorus unfortunately, if you remove those parts, there is nothing left in the tutorial
It's probably more like 90%
But hey 99% of statistics are made up 100% of the time
^^ I would go even higher
09:34
So...
@Sherif google "mysql php tutorial". Do you really believe that there will be one good tutorial in the first page?
Well any good tutorials on procedural php? I learned all basic php syntax but I have problems starting on the right path...like actually creating something with a good structure
I mean... you realize there are over 1 billion web sites on the Internet today. That's 1 website for every 3 people online in the world. What do you think the chances are one of them actually has something incredibly ground-shattering to tell you?
@Demorus why do you want it to be procedural?
I spent a lot of time on this github.com/PatrickLouys/no-framework-tutorial :(
@Demorus I would recommend picking up a book. My recommendation goes with this one: wrox.com/WileyCDA/WroxTitle/… (it's a bit older, but content is good)
09:36
W3schools seems outdates, TheNewBoston (watched all of them are ok but examples are outdated)
@Patrick because OOP is not suited for starters? What do you say?
I could always do OOP later
Stop thinking like that
It's ignorant
@Demorus I think that's because we are teaching it all wrong
"we" as in "php community"
@Demorus Can you give my tutorial a try? Would be a nice experiment actually to have someone do it without a lot of prior experience. If you get stuck somewhere just ping me in here :)
@Patrick it's missing the DB part
@teresko well im an apprenticeship so I dont have the luxury to go all "best practice" since they want me to create a few things and advance.
@Patrick sure man! All knowledge is welcome
09:39
That's even more ignorant than what you said earlier
@tereško I know, I'll write that in the next few weeks. I'll help him out in here with that if he does the tutorial
@Demorus I linked you to a book. Get it (in a shop or from torrents). Read it.
There is no compromise for quality. To say that learning good practices is a luxury is to say you don't wish to learn anything.
You don't have someone teaching you in the apprenticeship?
(Well if it's anything like mine then probably not...)
@Sherif kind of in a deadline you could say. My mentors tell me using mysql instead of mysqli is also fine as they want me to understand the concepts first, but since im hungry for knowledge I want to start with best practice first
09:40
Do you know how difficult it is to unlearn something?
@Patrick can i help in writing
@Demorus No, that's just utterly ignorant. What makes you think that learning something the right way is any more difficult than learning it the wrong way?
There are no shortcuts.
Whether you learn good practices or bad. They both take time.
There are, however, bad teachers.
That say ignorant shit like "it's ok learn it wrong now and we'll learn it right later..."
later never comes
later is a thousand tiny deaths to the ears of a developer
"If you don't have time to do it right, when will you have time to do it over?" -- John Wooden
@Sherif thats why im a bit in a hurry. I want to learn those good practices as fast as possible and show them results here at work before I do it the wrong way.
@Demorus You can put 20 guys in a room with a woman but it's still going to take 9 months to get a baby.
09:44
stackoverflow.com/questions/32178651/… that 3th line in his question, hahaha
@teresko I learned now to use dependency injection. Prepared statements and to keep the database credentials in a ini file outside the root. Anything missing?
Accelerated programs should have very stringent acceptance criteria for this very reason.
Most people fail to understand that.
@Sherif nice example! haha
morning
  $abc OR $b = false;
what does it mean ? ( is it like if $abc = true other wise it will assign $b false ) ?
There is a very unique means by which you can teach a student a very complex subject very quickly.
But in my experience, very very few people have that unique talent.
Believe me, I know. I've spent the last 9 years of my career trying to figure this out.
09:47
hi first time for me here
mine too :D
@tereško are you there ?
kinda
ok well, I have a unlimited internet now
09:48
how?
university?
may tell me how can I implement a virtualbox ?
@tereško yes
@AnmolRaghuvanshi feel free to send a pull request if you have another chapter or something else :)
ok, tell me how for you have got?
@Richerdfuld No, it just means the expression evaluates to false if $abc is not truethy. Which does consequently entail an assignment of $b, but not `$abc.
@teresko if I have a "connection" function with a parameter "x" how do I pass this over as a paremeter in other functions?
09:50
@Patrick ok... my first time so will try to do best..
So to avoid global or static variables
@tereško em, what ? should I download that 50MB file ?
@Demorus you can pass the same connection parameter to multiple functions
I can't remember the name of the meme but I need a picture of someone absolutely horrified (funny) for when someone's written some terrible code
@Sajad yes, you should.
09:51
@Jimbo ?
@tereško ok, just, you gave me two links, 50MB and 200MB, should I download which one ?
also, @Sajad, we probably should move this to chat.stackexchange.com/rooms/118/root-access
@FlorianMargaine Found one
and download the 50MB one, it will be faster
aha ok
@tereško ok
09:51
@Sherif thanks got it :)
2 mins ago, by Demorus
So to avoid global or static variables
@Sajad implement virtual box ? with what ?
@Jimbo , @FlorianMargaine , @Sherif .. help this guy out .. I need to do some tutoring about webservers
@Richerdfuld what is your mean with what ? I'm downloading it ...
@teresko @sherif here is a small jsfiddle jsfiddle.net/98ocr084/1 can you show me somehow how it is done with the parameters? I added there my interpretation of what you guys were explaining. Im not sure if I understood it but please do have a look
09:55
@Sajad how you implementing virtual box , we just dont implement we use it
@Sajad make a copy of whole tutorial on webserver by @tereško i would also like to learn
@Demorus Huh? Your code makes no sense. I think you need to go learn how functions work in PHP first
it will be more of a guided tour
@AnmolRaghuvanshi ok, but you should come here
can i join @tereško
09:56

 Root Access

For all you Super Users out there. You have backups, right?
@Richerdfuld I meant: how to use it :-)
I know how they work...or maybe I dont. I know what functions are and that they have parameters but...dont know. This case seems different to me
@AnmolRaghuvanshi you need download virtualbox and ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/10.2/…
ok just now i want to take overview...
I should really stop clicking on every link .... just downloaded freeBsd :/
09:58
:D
@NullPoiиteя it's good for the soul
@Sherif I know that functions can have parameters and that I can call the function with its parameters etc but... how to use it in this case with the connection variable is somewhat different
@Demorus How's it different?
is this close`? if not I will read through functions again
you know, some pseudo code. Mysqli often asks for the first parameter to be the connection
10:03
@Demorus Look, no offense or anything but your code demonstrates that you don't understand the first thing about functions. Read the link to the manual I gave you before yo assume you understand how functions work.
Sorry, AFK. I gotta take care of some stuff.
hmm ok then
@Demorus please don't use the static keyword to save state in your function... If you want to keep state, just use an object...
@Patrick well I just learned I dont know how a function works even when knowing what it consists of. This parameter part drives me nuts
@Demorus just use pdo and then pass around the pdo object... pretty sure people told you that earlier, why are you still using mysqli?
function foo(PDO $pdo) { $pdo->doSomeStuffHere(); }
ThW
ThW
@Patrick that works with the mysqli object, too :-)
10:11
@Patrick I thought I better understand the basics first. So then when I know the procedural stuff with mysqli I will head over to PDO OOP
mysqli and PDO in OOP are similar though in structure right?
@Demorus How many times do we have to tell you that this is a stupid approach and just wastes time? Just learn the right thing from the start
@Patrick they wont agree with me here at the working environment where I learn
why i am getting key value like this pastie.org/10372009 at php i want to get like pastie.org/10372011
i am sending from using ajax + json
So I need to find some middle path
I went with stack ...
also, morning peepz
10:13
@Demorus So they don't teach you and want you to write production code straight away? Good place...
ThW
ThW
@Richerdfuld You will get the format you send.
I was working on OOP but one of my mentors here told me I better start with procedural.
ThW
ThW
@JoeWatkins Morning
Since it is easier to grasp
@Patrick how do I tell php to use the connection within the function inside another function? jsfiddle.net/98ocr084/3
@Demorus Then tell them you can't find a good procedural tutorial but you found a good oop one... ;)
@Demorus pass it in as a parameter
function foo($connection){}
10:18
@Patrick seriously, it works?
Yes. But you need to pass it when you call the function, so:
$dbStuff = getMyDbStuff($connection);
That being said, objects make this much nicer because you first initialize it with the dependencies and then you don't have to pass it to each method on the object separately. With functions you don't have that option
because you know when there are those mysqli functions that require the connection as the first parameter...when I have those within a function I always had to specify my connection variable as a global.
@Demorus Can't help you with that, I don't use mysqli (because PDO is better)
How about running this regex on your #ZF2 templates? Not much, but you’ll thank me later http://goo.gl/raaRBt
just a shout-out if anybody is using ZF2 around here... Because I know you didn't get your app pen-tested ;-)
@Patrick I will use PDO. Is it hard to learn for a starter and newbie in the world of programming? Oh and here my new jsfiddle. Is this what you mean? jsfiddle.net/98ocr084/6
ThW
ThW
10:27
@Demorus Actually $connection is an MSQLi object, you can call $connection->query($query), too.
@Demorus here is a small class that uses pdo pastebin.com/iaeCsLYh
If you insist on using functions, then you have to pass in the pdo directly to getLastWeight
why does he use jsfiddle for php code??
its like [insert analogy here]
@MarcelBurkhard I know its just for javascript but hey, it works lol
So when I know PDO then I already know most of the mysqli OOP stuff right?
the differences are in the nuances I assume
@Demorus PDO is a cross-database object oriented interface
@Demorus e.g. you can use a sqlite database (file based)
mysqli is just for MySQL, it's not OOP and the main benefit over mysql_* is that it enables you to use parameterized queries (which prevent SQL Injection attacks)
I wouldn't call this... nuances... tbh
I think for your desired quality of code, mysqli is a good fit.
10:44
PDO also has named parameters
What do you say about this answer`? stackoverflow.com/questions/241311/…
@Demorus you linked a question with multiple answers, pls be more specific
The one with the accepted answer
yeah now what exactly is your question ? I don't have anything to say about it other than that it is probably not relevant to what you're doing
Well the thing is I have the database connection wrapped in a function
and the other functions need to access the variable inside that function that stores my database (mysqli_connect stuff). Somehow Im confused on how to do a dependency injection without OOP codeinphp.github.io/post/dependency-injection-in-php
10:52
what the...
dependency injection without OOP is insane
hey im a nooblet Marcel. Need to learn the basics first : (
check this out, what do you say? jsfiddle.net/98ocr084/7
no the thing is you don't listen to us
@Demorus if you don't want to use Classes... use Globals
Oh damn, ok fine. So can I leave out procedural and go directly with PDO as a newbie in programming and php?
$GLOBALS['connection'] =
I will read on globals
10:55
@Demorus basically when you have a script and say $a = "a"; then $GLOBALS['a'] = "a";
$GLOBALS is just to make it more clear that you use globals
but it is somehow the same as using global keyword for php right?
I think so, don't like that though
@MarcelBurkhard could you please shut up? you are teaching bullshit to a newbie
global $var 'imports' $var into the current scope, from the global namespace. Which then couples your current scope (usually an object) to something it shouldn't care about that can change outside of it at any time. This is why you pass your things that can change in, (called dependency injection, but really it's just passing object / variables into the object via it's constructor or methods).
Oh crap
Im going all rotten. Ok here a scenario. I am a newbie in php and never learned any programming before. Should I try PDO or continue with procedural?
10:58
@tereško I think knowing about the $GLOBALS array is good though, I used it for new stuff in old projects, e.g. : $dbh = new PDO('mysql:host='.$GLOBALS['db_host'].";dbname=".$GLOBALS['db_name'], $GLOBALS['db_user'], $GLOBALS['db_pass']);
Oh and knowing I have to advance here at work even if I only learn somewhat older methods
@Demorus go PDO
@Demorus Continue with procedural, learn the syntax, idiosyncrasies, but keep OO in your mind as you go along. Eventually you will start having trouble with the huge spaghetti code that your procedural becomes, and then you yourself will choose OO as a solution to that problem
ok Marcel says PDO
But why not choose PDO, it's only one object, you don't have to write OO code to use it
10:59
totally
Jimbo says Procedural

« first day (1773 days earlier)      last day (3400 days later) »