« first day (642 days earlier)      last day (4305 days later) » 

user895378
1:00 PM
@vascowhite +1
 
@vascowhite statics are easy to test...
code that uses statics is difficult to test
 
hm they have their right to exist
 
@ircmaxell Yes, you are right, I hadn't thought that deeply about it. I just found unit tests involving statics messy and difficult, so I stopped using them. I found that post when I was trying to find if I was doing something wrong.
 
@jami What does?
 
@jami I didn't know code had rights
 
1:04 PM
@PeeHaa class methods
*hehe no i mean class methods in the oop paradigma itself
 
I must have forgotten to read "The bill of digital rights" :)
bit rights?
 
@jami static class methods ? Why ? How are they different from simple namespaced functions ?
 
Many languages do not allowing standalone functions
 
@jami so?
 
php is like a patchwork carpet
like c++
there is no difference
 
1:07 PM
none at all.
 
@jami , so your reason why static methods are ok is "because in other languages you cannot have standalone functions"
that would be funny , if it was not so sad
 
aehm no. Ever written a singelton pattern without static creator?
show me
 
user895378
lol
 
@jami hihi
 
wait ! what ?!
 
1:10 PM
Wow, my work web filter has the internal mailing list archive blocked. wtf
 
@CharlesSprayberry proxy it like a boss
 
@jami , are you aware that singleton is an antipattern which tries to mimic global variables of bad procedural code with syntax of object oriented code ?
 
is that so in your world
 
and in the real world :)
 
@jami And what world are you coming from. You've taken the red pill?
 
user895378
@jami @tereško's world, my world, your world, Cinderella's world, parallel worlds, etc.
 
interesting opinion
 
@jami , the point is , singletons are not in the object oriented paradigm
it is a hack and an anti-pattern
 
1:14 PM
so the GOF and martin Fowler are wrong
i see
creational pattern are anti pattern?
did i sleep for a long while?
 
class StructureFactory
{
    public function create()
    {
        $args = func_get_args();
        $name = $args[0];
        array_shift($args);
        $object = call_user_func_array(array(new $name(), '__construct'), $args);
        return $object;
    }
}
@tereško amidoinitrite? xD
 
sorry .. typo
 
$factory->create('View', 'blog');
can it be called like this?
 
that would actually be a Builder
 
(with some magic)
I see
 
1:17 PM
but the line between builders and factories are pretty blurred
when you are dealing with simplified examples , the look almost the same
 
user895378
Did you seriously just invoke the powers that be in defense of your wrong opinion? Check your facts bro: the GoF strongly considered adding a diatribe against Singleton in the second edition. And it's been a long time since anyone thought Singleton was a good idea. Have you ever even visited Martin Fowler's own site?
 
user895378
@tereško ah you beat me to it
 
@tereško thanks man
 
If you have said "avoid class methods where you can" then i would agree. But this way .... no
 
@jami , what ?
you seem to confuse normal class methods with static ones
because you never specify which ones you are referring to .. as if people might get confused and start agreeing with you
 
user895378
1:22 PM
Not to mention Fowler's been wrong before. His work on Service Locator is now also considered an anti-pattern.
 
user895378
"Person X said this is good, so it's good" is the worst kind of argument there is.
 
Class methods ARE static methods
 
:(
 
I don't named them so
its calld class method
 
user895378
yay globals! static everywhere! makes coding so much easier!
 
1:25 PM
no that is stupid
 
user895378
So it follows then, that singleton is stupid by your own admission.
 
no
 
Hello All, i know a little PHP/MySQL but i want to imrove my php skill, can anyone suggest some links for project tutorials? BTW, i'm C/C++ programmer, so i dont need to much about loops or etc..
 
user895378
Because that's what Singleton is.
 
*sigh
 
1:26 PM
checkmate
 
no just a stupid answer
 
@jami , how are global code structures (global variables and standalone function) different from static ones ?
 
"Either you use it global and on every corner or not" Thats what u say. That is stupid
 
user895378
You do know what Singleton is, right? You understand how it works? You don't have it confused with dependency injection or some other practice that doesn't hide global state behind the static keyword, right?
 
user895378
Clearly you don't.
 
1:28 PM
yeah whatever you said
 
@tereško Hell, i know a little PHP/MySQL but i want to imrove my php skill, can anyone suggest some links for project tutorials? BTW, i'm C/C++ programmer, so i dont need to much about loops or etc..
 
@ilis , if you know the syntax , then i would recommend reading PHP Object-Oriented Solutions and/or PHP in Action ( the first on is better, IMO )
 
It must be the ultimate truth
 
user895378
Well, I've done my Mitzvah for the day. All you can do is try.
 
whatever
 
1:30 PM
static method is normal function wrapped in class, true?
 
ask @rdlowrey
 
@ilis also , try to avoid books which advertise as "explains php AND mysql" .. they are usually full of crap. You will be better off by getting a good MySQL-only book to learn the basics , and if you already know SQL basics , then read SQL Antipatterns
 
well I learned a lot from @tereško and @rdlowrey ... but that I know myself from the beginning... @jami
 
4 mins ago, by tereško
@jami , how are global code structures (global variables and standalone function) different from static ones ?
 
ask @rdlowrey
 
1:32 PM
i know SQL and alittle of mysql, but not so good. PHP manuals to seem to be a little coplicated, maybe not complicated but need too much of time&work. Thanks @tereško, i will try these books
 
user895378
@jami I'm pretty sure he asked you. It's called the Socratic method.
 
@ilis "need too much of time&work" Doesn;t sounds like you are willing to learn
 
sorry .. i have never had any training in debates
 
@ilis manual is pretty much best resource when you have basics covered...
 
@ilis , also , this might be useful for you : wiki.hashphp.org/Main_Page
 
1:34 PM
or "php the right way" :P
 
@webarto or not , i still think that you should avoid that "php the right way" site
 
forgot [sarcazm] tag :)
instaunfriend
and the guy is "lead developer"
 
@PeeHaa i have experience with Objective C, C, C++ and also java, and also i have written a little for some of my app's server side iin php and mysql too. i do will to learn
 
Does this seem like a terrible idea, or is it just me? babylscript.com
 
@PeeHaa i tought the ones in this room must have experience with php and also with the approach how to learn it, for example @tereško suggested a few books but you say manuals are best. this is related to point of view.
 
1:39 PM
@ilis he is talking about the php.net manual. It is actually more like code reference then manual
 
thanks in advance to both of you @PeeHaa and @tereško
 
@deceze as we are not having hard time communicating in English :)
 
@deceze , if you cannot read & write in english , stay away from athgin that is related to computer science
 
regardless of English, it should be uniform...
 
someone needs to teach that PHPtherightway guy CSStherightway
 
1:45 PM
Looking at some of the translations, it totally throws the grammar of the target language off. English has pretty simple grammar, something like German doesn't. "Programming in German" would still feel extremely foreign and stilted unless there was also a fantastic inflector built in.
 
IE: why is the menu in a pane -__-
 
And something like Japanese has the grammar totally "backwards" to begin with, so it makes even less sense if the constructs are still in the same order... -_-;;
 
well at least the guy suggests PDO
 
@deceze , hey , i learned programming by reading books in russian .. german is easier
 
@tereško I honestly think German is one of the easier languages to learn
 
1:47 PM
@tereško Then I'm interested, how do these translations sound to you? babylscript.com/mappings/ru.html
 
have you tried learning Japanese?
 
it has 4 grammatical cases @tereško my language (somewhat similar to russian), has about 7
 
@Event_Horizon , am am currently learning japanese =P
 
english rocks :)
 
return -> rücksprung - Really? rücksprung wahr;? Makes less sense than ever.
 
1:48 PM
Chrome was like: This page is in russian would you like it translated?
 
@tereško 頑張ってね。:-3
 
Good morning again
 
when translated from the russian page: toSource= vIskhodnyyTekst
 
@deceze your keyboard is broken :P
vizvori
 
@deceze , tnx
 
1:49 PM
that is BS
words have completely different order
 
@webbearrto Yeah, it happens... :-/
 
lemme change my nickname :D
 
@tereško, @deceze, are you russians?
 
@Kir Njet.
 
latvian
 
1:51 PM
ah... ok ok
 
@tereško I don't know any Kanji but I know like, two phrases, tried self teaching it in high school, didn't go to well (German went much better)
 
durak
 
There is a business platform in Russia called 1C. It is very powerful and have it's own programming language that is using russian language.
 
@Kirzilla , somehow 1C makes me think of pirated games that i bought while i was in highschool
 
@Kirzilla To keep it secret from western spies? ;)
 
1:54 PM
@tereško, yup. It is the same company, but another division :)
@deceze, yeah and increase 1C specialist value in labor market of 1C developers :)
 
@deceze حظا سعيدا.
 
@sehe Gesundheit.
 
ok so I have a variable that is coming in as an array - but in some edge cases it will be passed as a single string (taken out of an array) so I need it to be encapsulated in an array again.
$str = array($str); or $str = explode("",$str); or anything else better for this? (of course all of this is in my is_array($str) check )
 
Just gonna use closures for the first time, anyone is really using it?
 
cheers? @deceze nazdravlenia
 
2:00 PM
@rlemon , then my not create two separate functions ?
 
@FabioCosta what does that mean?
 
one for string and one for array
 
@FabioCosta, I'm using it everyday
 
@webarto Closures? Is those like anonymous functions
 
@FabioCosta yes and yes they are useful
 
2:00 PM
@FabioCosta , yes
 
or lambda function
 
because it's rendering html. 99% of the time the values to be rendered in the table are in an array of rows. certain edge cases require it to be passed as a single string (one row) and yes the obvious solution would be to fix these edge cases but first i'm just looking to correct it on the view.
so just a simple conversion there would suffice if the expected array is in fact just a string.
 
function random_sentence_spin($str)
{
    $new_str = preg_replace_callback('/\{([^{}]*)\}/im', function($matches) {
        return explode('|', $matches[1])[mt_rand(0, substr_count($matches[1], '|'))];

    }, $str);
    if ($new_str !== $str)
        $str = random_sentence_spin($new_str);
    return $str;
}
 
@FabioCosta , just keep in mind that php has different variable scoping then javascript
 
@rlemon if (!is_array($foo)) $foo = array($foo);
Or possibly $foo = (array)$foo;, if there's no chance of side effects for you.
 
2:02 PM
@tereško I will just use it for keep the scope of tree levels and parents from some dataset
 
@deceze , wht that , instead of $foo = array($foo) ?
 
because if it is an array, it would be 2D then, or not
 
@tereško Simply $foo = (array)$foo; without is_array check.
 
array() is a function (array) is a cast
 
you don't say :P
 
2:04 PM
@deceze .. oh
 
yeaha
 
$foo = (array)$foo; will be ok?
man I feel so c#
 
@rlemon If it's already an array, it will do nothing. Otherwise it will cast the scalar value into an array, which is usually the same as array($foo).
 
sweet.
 
Check the manual for casting rules to make sure you won't get undesirable side effects.
 
2:05 PM
it's thursday, thursday, day before the friday, weekend, weekend
 
like information lost
 
undefined variable 'foo'
:<
sad panda :P
 
typo
 
@Donut repost of a repost is a repost :P
 
2:09 PM
   ☹
 /(O)\
 ((O))
~     ~
 
31 mins ago, by deceze
Does this seem like a terrible idea, or is it just me? http://www.babylscript.com/
 
Oh, damn
 
no
its terrible
 
awfull idea
 
+1
 
2:11 PM
I am getting a little nervous for the HTML5 JS overwhelming that is coming, Firefox and Tizen being Mobile OS's with HTML5 with all programming being made trough JS, or like using Phonegap for mobile
 
as i was a kid i do that by myself. I setup a big macro header file to write a pascal hybrid in c. It was fun but a bad idea ;)
 
pokit.org/get/img/cba6a509b7875b3b6888b71396b96fc4.png :( this is going to get posted on nettuts (7 useful functions, sigh)...
 
403
 
@deceze yeah, it's a terrible idea. turns your namespace into a minefield; every function gets a hundred possible names, maybe 10 of which you have any clue at all about? what happens when the english and french (or spanish, or german, or....) names collide?
 
@cHao Not just that, it makes code interchange virtually impossible. As if copy-pasting random forum code wasn't bad enough already, now you have no chance of being able to understand it. So far "code" was at least the Esperanto of programmers...
 
2:22 PM
figures all the examples are in fscking french too...lol
i bet they'd eat this crap up
 
What small custom functions are you using every day?
Like this one
`
function isset_or(&$var, $value) {
if (isset($var)) {
return $var;
}
return $value;
}
`
 
@webarto wut?
 
@PeeHaa what have I done?
 
can a closure call itself?
 
lol
 
2:26 PM
Was looking at the image...
 
that would be very interesting
 
@Kirzilla otherwise known as $var = isset($var) ? $var : $value;
@Kirzilla and please don't abuse references like that...
 
@FabioCosta Recursive closure?
 
@jami Yes
 
considering a closure could have access to the variable that contains it...
 
2:26 PM
you are nuts :D
 
i'd say yeah.
 
In that case i think i better use a function
 
@PeeHaa yeah, all wrong :( and they'll come here and say they've read it on nettuts+ ... guys that write this s* don't like me because I always object...
 
@FabioCosta yes, it can
 
@cHao yes but the readibility
 
2:28 PM
@ircmaxell Thanks
 
$foo = function($a) use (&$foo) {
   if ($a < 100) {
      $foo($a+1);
   }
}
 
@ircmaxell I'm using reference here to avoid generating notices if variable or array index do not exist...
 
@Kirzilla and that's an abuse of references, please don't abuse references
 
@ircmaxell Thanks a lot
 
in Lounge<C++>, 1 min ago, by Cat Plus Plus
Also PHP room on SO is 20 times smarter than average PHP user.
2
 
2:29 PM
lol
 
@sehe Only 20? I take offense to that...
 
@jami i'd say the readbility is enhanced. At least with a recursive closure, you can tell right from the signature that it's recursive.
 
@ircmaxell lol
 
@irc The average is just being dragged down by the rest of us, you alone would be infinity smarter. ;)
 
easy there fanboy :P
also, good morning
 
2:32 PM
Morning, fangirl.
 
@deceze I still take offense to it. Yes, there are some dumb people who come in from time to time, but the vast majority of the regulars here are way more than 20 times smarter than the average PHP user (or perhaps I've just met some REALLY dumb ones)...
 
@CarrieKendall morning
 
20 times?
(ノ゜-゜)ノ ︵ ┬──┬
 
you've probably met quite a few really dumb PHP programmers.
 
@cHao hm thats true
 
2:33 PM
@webbearrto Whatsit with you and that table?
 
@ircmaxell shrug, just someone else with an opinion.
 
today is the table flip day and Italian nickname day
 
:-P
 
so what's the word? (inb4 the bird)
 
nice song btw
 
2:36 PM
@ircmaxell Don't worry, it's just a meme someone unrelated spawned.
 
:-P
 
And much more stupid at that.
 
trashmen surfin bird
 
You see, he earns 20 times as much as we do, so he knows better.
 
Any comments on this? http://www.php.net/manual/en/function.require-once.php#103462

Is doing something like that a good idea?
 
2:38 PM
jesus el cristo savior
 
@Event_Horizon Don't know what it does, but no
 
Hey all what is
 
Hm i think there are better class loader
 
up
 
@Event_Horizon Why not use a LOADER?
sorry for the caps
 
2:39 PM
NP
 
Autoloader i meant
 
@Event_Horizon use an autoloader...
 
@Neal right, I was just asking if the suggested practice was shit
 
Where can I find phpDumbassMeter ?
 
@Event_Horizon it is.
Just bc it is in the docs, does not make it good at all...
 
2:45 PM
do you guys use __autoload() or spl_autoload_register() usually? or neither?
 
@Event_Horizon spl_autoload_register()
 
depends on
 
@MikeB alright, thats what I thought
 
@Event_Horizon spl_autoload_register() .... using __autoload is gonna wind up causing problems as soon as you need more than one autoloader or attempt to use a library that supplies their own
 
> If there must be multiple autoload functions, spl_autoload_register() allows for this. It effectively creates a queue of autoload functions, and runs through each of them in the order they are defined. By contrast, __autoload() may only be defined once.
 
2:46 PM
yeah.. spl_autoload_register is better. for one, you can register multiple autoloaders
 
loving the new bracket notation for arrays :D
 
so &$var in a function paramater tacks it to the end of your input?
 
lolwut
 
going through language reference
just wondering how "Passing function parameters by reference" works, never used it
there's only one example and its this:
function add_some_extra(&$string)
{
$string .= 'and something extra.';
}
$str = 'This is a string, ';
add_some_extra($str);
echo $str; // outputs 'This is a string, and something extra.'
makes it look like it tacks the $string on the end of the function input
 
@Event_Horiz, passing var by reference means that we're passing not variable value, but address of memory block where this variable being stored.
 
2:52 PM
@Event_Horizon , do you know what .= does ?
 
the nick is funny
 
@tereško yes
 
then what is your question ?
 
@Event_Horizon A good use-case are passing objects by reference into functions.. so when the function alters the object, it's changed in every scope. Objects have been passed by reference by default since 5.x
 
@tereško I was just making sure I understood it properly, never used it in a function.
 
2:55 PM
@MikeB WROOOONG
in php 5.x you pass objects by handler
if you start passing them by reference in php5 , you are messing with refcount
 
@tereško, please explain what's the difference?
 
how do you format multiline code in chat?
 
> One of the key-points of PHP 5 OOP that is often mentioned is that "objects are passed by references by default". This is not completely true. This section rectifies that general thought using some examples.

> A PHP reference is an alias, which allows two different variables to write to the same value. As of PHP 5, an object variable doesn't contain the object itself as value anymore. It only contains an object identifier which allows object accessors to find the actual object. When an object is sent by argument, returned or assigned to another variable, the different variables are not a
I suck at quoting
 
2:58 PM
@CarrieKendall you press shift+enter
or alt+k for source code
 
@tereško but ` this ` stops working?
 
yes
 
okay, thanks :] i just assumed i was doing it wrong (this is generally the case)
 
@tereško Doesn't that essentially amount to the same thing since php uses copy-on-write?
 
no , because when you write to an object , you do not change the handler , and there is not copt-on-write then
 
3:01 PM
@tereško What are the implications of that to a developer?
 
it means that if you are using references with an object , you will be causing memory leaks
the refcount gets messed up and your object is not garbage-collected
 
interesting - thanks for pointing that out
 
stupid CodeIgniter, if i define my db config for a second db in databse.php and use $this->load->database('group_name', TRUE); it wont connect, but if i define the configs in an array just before the $this->load->database($dbConfig, TRUE); it works
I NO WANT TO DEFINE CONFIG IN MODEL
 
I guess that means func($myObject) !== funct(&$myObject) ?
What situation would you want to use the latter?
 
@MikeB None, I guess?
 
3:06 PM
@gorelative I got 99 problems, but a Framework bug aint one.
 
they will act the same on the surface , but under to hood one might cause to object to keep floating in the memory even after you have "destroyed it
 
i wonder if its because im calling $this->load->database() in the model..
figured it out, apparently if you can use $this->db even when you don't autoload the database library... addded database to autoload and now its loading configs from databse.php lol
another thing i noticed, Codeigniters profiler doesn't catch OCI8 queries...
 
0
Q: If Objects are passed by alias when would you pass by reference?

Mike BAccording to http://php.net/manual/en/language.oop5.references.php One of the key-points of PHP 5 OOP that is often mentioned is that "objects are passed by references by default". This is not completely true. This section rectifies that general thought using some examples. A PHP referen...

 
3:37 PM
They are not passed by alias or reference
 
dang
 
Are we blaming PHP / out host for our own stupidities now?
> One little change in PHP5.3.10 or so wiped out a whole block of mine, and the
fix involved a re-writing all the <?= code across many pages. Simply because the
ISP would not switch back on short tag.
 
yes
 
@PeeHaa Lester ;)
He is kind of ...
Let's just say that he's the kind of guy who runs display_error=On in production
Actually he said that some time ago on the list, because "He wants to know about errors immediately" or something like that ;) And that nobody is checking the error log anyways D.
 
I just want to go right in and tell him that he is an idiot (in more political wordings ofc) :D
 
3:50 PM
@PeeHaa "You sir are an idiot!"
 
> the fix involved a re-writing all the <?= code across many pages

Mission accomplished then, I guess? Good work, PHP team/host!
 
hehe exactly ;)
@NikiC Or: You sire deserve a punch in the face
 

« first day (642 days earlier)      last day (4305 days later) »