« first day (2415 days earlier)      last day (2542 days later) » 

10:00 PM
@Wes I'll look at every repro…
as long as it's a repro without 100 kLoC…
 
Wes
could be :B i tried removing some stuff but didn't fail. it's not just ... it's something that doesn't get garbage collected
 
@Wes just show it…
please.
 
Wes
i actually have a problem posting my code @bwoebi i've been ridiculed every time i did that. so i want to clean it first. it's your fault
:B
 
@Wes I won't ridicule you… feel free to show it to me in private, if that's your concern.
 
Wes
if i find the strength i will do it tomorrow
 
10:15 PM
@Wes I'm sorry
 
Wes
did you ridicule my code too?
 
I don't know, but y'know, my canadian unsure side insists that I be sorry
 
Wes
your canadian side
what happened to kill the boy
 
:P
I read that part with Reek
 
Wes
lol
 
10:18 PM
the boy came back crying
dude, that Ramsay
 
does anything happen (besides stopping the execution of the function) if a function returns something but it was called without being assigned to something or in a context where that makes sense?
 
Wes
which is worse, book's ramsay or tv show's?
 
can't totally tell yet, but I believe book's will win, with a clear margin.
 
@Julix wat
 
@Julix also, you might want to remove your door number from SO account
it's really public
 
10:21 PM
@FélixGagnon-Grenier but how will we know where to send letters with powdered sugar?
 
heh
is that a anthrax reference?
 
yes
 
@FélixGagnon-Grenier was outdated, but good catch! fixed
$catz="";
function lolcatz(){$catz="hahahha"; return false;}
a = lolcatz(); // a is now false, right?
lolcatz(); //does the return do anything here?
 
@Julix yes, and yes
 
you will actually get "function not defined"
 
10:23 PM
however in the second case, it's not assigned to anything so, nothing happens
 
also, the $catz will not get changed, because it not in the scope
scope in php works differently than in javascript
 
@tereško gha! you're right! (just tested it in disbelief) - so how do I get it out? must I return? -- certainly don't want it global scope... just one up
 
what do you want to actually do?
 
@tereško one function to be able to mess with a bunch of variables before returning true or false based on whether it was able to do everything I wanted it to --- and I was already doing that successfully by modifying an array before knowing that it's not supposed to work, that's why I was so shocked. I guess at that point I was modifying an array that was passed into the function, but I didn't return it back out... --- AHH! but the array happened to be a global (_FILES and _POST)
 
ehh .. I dont even know where to start fixing it
 
10:29 PM
Right now I'm reading php.net/manual/en/language.variables.scope.php - might help :D -- EDIT: Turns out _POST is a superglobal, right?
 
php, the way I understand it, has 4 different scopes: global, class, function and object
 
Yes, scope. And in PHP I'd say that function parameters are of good use here. There are anonymous functions with a use-clause but then, why not using function parameters.
PHP has 2 scopes, global and local.
 
@hakre what about superglobal (i.e. where you don't need the global keyword)
 
@Julix Global variables you don't need the global keyword for. But still just global scope. These variables are only super (omnipresent).
 
@hakre I see your point, same way that there's different ways of getting local scope, but once you're there it's the same rules -- unless @tereško is right with the 4 scopes... - is there a scope-related difference between the local scopes?
 
10:35 PM
No, there is no difference between the local scopes. There are some object properties / class variables that have a certain visibility, but that should not be conflated w/ scope.
E.g. $this in object methods is a local variable you don't need to define.
 
@Julix if I understood you correctly, to do what you want, you would need to go full-OOP
 
@hakre alright, thanks! :) -- so my question then is, how do I mess with things outside of the current local scope -- and the answer is: you don't. Bring it into the local scope and return it out when you're done.
@tereško I miss JavaScript so much! Intro level PHP (up to associative arrays at this point) is hard to adjust to after having access to classes!
 
yeah ... starting with JS as your first language can seriously fuck up oneself
7
 
@Julix You don't need classes for that, what you describe sounds a well fit of functional decomposition.
 
@hakre the way I read it, you would need to pass in references, to do what he want ... and that would lead to a whole different world of pain
 
10:42 PM
I'm glad I started with JS, wouldn't have gone with it otherwise. Being able to change things in a super-visible way (i.e. chrome console) was a high impact experience for me. Then adding HTML + CSS meant I could do something (simple but pretty front ends). Pays the bills too. Sofar the WordPress stuff I've made is simple enough, too. - But eventually (next couple years) I want to get into web apps and go full stack, so that's why I'm so concerned about brushing up CS basics and learning OOP.
 
If passing by reference seems necessary, then decomposition leads to more than one function.
If you're coming from JS, then you might find anonymous functions with the use clause more straight forward: php.net/manual/en/functions.anonymous.php
 
I do a bunch of stuff to check whether the _FILES array contains a valid image and whether the _POST array contains all the necessary input. They're both related to handling the form submission, but since they're mostly unrelated I have them in separate files... but before finalizing and saving the submission I need to check if both is done properly.
 
As long as you have read only access, pass them as parameters.
 
@hakre need to write as well, so I was tempted to pass stuff between the two, but that would be referencing things out of their own scope, so maybe a new, higher scope can capture both and then they could just return things from within their own scope to the caller (one higher) who puts it all together...
wait a second, I'm working with _FILES and _POST -- they're already superglobal - can I just modfiy those or is that against best practices? --- Should have mentioned my script is already doing what I'm asking it to, I just find it ugly and want to make it more readable and proper and better...
 
Yes, you can modify those. And yes, using superglobals is considered a smell and against best practices.
However, before creating objects to modify the input values (_POST, _FILES), you can operate on these "singleton" variables as well. Just keep in mind you bind your code to these.
That is your code will likely only work within the webserver context with these superglobals.
And your code changes the global state of the runtime (hard to test in isolation).
 
10:49 PM
@hakre ah okay, not just me finding that smelly then. :) -- since both objects come from the client they could modify those too, right? I figure that's one source of why it's bad. They could read anything that I attach to it and change it (if my code doesn't check for that properly) and then get around validation by just changing my _POST['success'] to true or whathaveyou
@hakre I've heard the word before, I'll go look... en.wikipedia.org/wiki/Singleton_pattern --- too OOP for this homework, sadly.
 
@Julix I did not mean the pattern, just that there is only one $_POST in the whole script. Object was mean not as class instance but just variable or even more simplified memory address.
 
@hakre oh... well then I'm not sure I follow. -- from a few min of looking all I see is references to classes...
 
@Julix If you modify the superglobal, you modify it. It's modified everywhere, global scope. That's all. You can not change a supgerglobal temporary as if you have a function parameter with it's own local scope. Also superglobals are variables containing arrays, not objects. Sorry for misleading earlier.
 
Wes
@bwoebi ironically i've found a similar issue.... but that was easier to solve. after a goto something is not cleared. was using it temporarily. after i removed it the problem disappeared :B
 
@Julix singleton is a glorified global state - it's an antipattern
 
10:55 PM
@tereško hehe. alright. So what if I just make it return a "$return_array" and then itterate through that to get the contents that I want out? -- just thinking about it smells a bit... but my codenose isn't trained, so that doesn't have to mean anything.
 
STOP
stop editing the dame fucking sentence and pinging me all the fucking time
 
sorry, didn't realize edits pinged -- and won't mention you by name anymore. didn't mean to inconvenience you, thanks for letting me know
 
11:20 PM
hehe
 
11:38 PM
 
Awesome! turns out there's actually a popular question like that: stackoverflow.com/questions/16201656/…
 
nice @tereško
 
11:55 PM
@tereško cringe @ the comments
 

« first day (2415 days earlier)      last day (2542 days later) »