« first day (1353 days earlier)      last day (3600 days later) » 

12:28 AM
@samrap actually, your page application should have only a single point of entry
the rest of PHP code should be placed outside of DOCUMENT_ROOT
@HamZa that is only slightly true, if your server NEVER decides to show visitors raw php source ... which, in my personal experience, happens way too often for ones comfort
@Danack this has nothing to do with frameworks
 
@tereško I was saying that he should look at some frameworks to see how they implement a front controller.
 
well ... they either do it "extremely badly" or "extremely complicated" .. and IMHO, symfony manages to combine the both options at once (it parses pre-compiles the routes using eval() for example)
 
I see
 
I'm not sure that it does any more - they changed the router to be less shit. But it's still a lot easier to look at a code example to see a front controller works at all, rather than trying to imagine everything if you're currently having separate php files for every end-point on your website.
 
even if they have fixed it, Symfony would be one of the less-intuitive examples out there
 
12:52 AM
How can this be?
var_dump:
string(74) "ID=&category_id=&product_name=&product_price=&active=&stock=in&date_added="
string(98) "ID=&category_id=&product_name=&product_price=&active=&stock=in&date_added="
And when I try to use the second var in a header redirect it keeps changing "&" to "&"
 
var_dump with xdebug ?
... oh
 
Essentially what I'm trying to do is convert "$_POST" to a query using http_build_query but it's not going so well for me.
 
Jay
1:32 AM
hey guys
I am about to release my ecommerce plugin for my cms
would anyone like to demo it for me?
there are a few bugs
bitcoin payment is added
design issues are not important
 
 
3 hours later…
4:35 AM
moar-morning
 
4:57 AM
Good Morning
 
5:25 AM
$a = array(800.00,2000.00,2000.00,1000.00);
$d = 3500.00;
i want to subtrack $a array from $d from array end ?
 
could you be more specific
 
result would be $a = array(800.00,1500.00);
 
so it takes the last element out and subtracts, if not 0 it continues to pop the next one?
 
yes
 
=] So what have you tried so far?
 
5:30 AM
i done it using JS
 
but I guess you are solving it in php now? Should be quite similar. Have you tried before you asked?
[=
 
nope
 
Please do so before asking
 
5:59 AM
 <?php

$a = array(
    800,
    600,
    500
);
$d = 600;
$r = array_reverse($a);

foreach ($r as $k => $v) {

    if ($d > $v) {

        $d = $d - $v;

        unset($r[$k]);

    } else {

        unset($r[$k]);

        $r[$k] = $v - $d;

    }

}

var_dump($r);


?>
I want to substrack my array from given value from array end
does anybody help me for this ?
 
@samitha sorry but, how can you work as a Senior System Developer at Srilanka Largest education Network? You should be able to solve this?
 
I'm confusing when doing such a thing man
i'm only perfect for JS
 
Well this is quite achiveable.. you should be able to fix this yourself, do not ruin it for yourself by asking people how to fix this, you need to work out the brain so you can solve something like this another time
and it has many solutions..
 
morning
 
6:25 AM
morrowing
 
Morning
What might cause PHP not to respect set_time_limit?
 
6:41 AM
sleeps? safe mode? max_execution_time?
 
@SergeyTelshevsky sleeps
How do sleeps affect max execution time?
Ah I see
 
@SecondRikudo E_NEED_CONTEXT
 
@AlmaDo Nah, it's the sleeps
Thanks @SergeyTelshevsky
 
common mistake, yes..
 
Now how to get around it XD
 
6:47 AM
Guut morning!
 
hi, @Duikboot
@SecondRikudo ?
 
Yo @AlmaDo
 
@AlmaDo I need to have delays in my code, but I still don't want it to exceed 30 seconds of runtime
 
@SecondRikudo > /dev/null & ?
 
@AlmaDo Eh?
 
6:51 AM
@SecondRikudo lame :D
 
How does clearing /dev/null give me a delay?
 
I mean - add that to your syscall
 
@SecondRikudo I think you should simply put some custom timer and a custom sleep function that will raise that will be deducted from the counter
 
so your script won't delay on external call
 
@AlmaDo I am already logging to a log
> log.txt
@SergeyTelshevsky I think I'm just going to check time() in my loop and compare it to the one at the beginning of the run.
 
6:53 AM
@SecondRikudo in any case, if you'll tell us whole issue, that would be easier to help. for now - declare + timer is an option
 
@SecondRikudo yes :)
 
@AlmaDo I am sending out curl requests
Sometimes they fail.
In case they fail, the retry in a loop with sleep(5) in it
But I don't want the script to pass 30 seconds of execution no matter what.
 
@SecondRikudo replace sleep with loop + usleep. And add ticks to your script, where you'll check if time limit wasn't exceeded
 
@AlmaDo How's sleep different from usleep?
 
@SecondRikudo they are not external call. Oh. wait usleep is. So it's just redundant
you can remove it
 
6:56 AM
@SecondRikudo you will have to do a loop and check the time manually
 
@SecondRikudo so just loop without anything + ticks
 
@SecondRikudo
declare(ticks=1);
define('TIME_LIMIT', 5);
define('TIME_LAUNCH', time());
register_tick_function(function()
{
    if(time()>TIME_LIMIT + TIME_LAUNCH)
    {
        echo('Fatal error: (timelimit message)');
        exit(1);
    }
});

while(1);
so, without (u)sleep calls
 
without usleep it will consume CPU
 
it will :(
 
7:03 AM
so why not add NNNms delay
 
well, that's an option. I was about to show the thing..
 
show the thing..
hehe
 
@AlmaDo But I need the sleep calls....
I want to wait 5 seconds between each failed request...
 
@SecondRikudo you need them to produce delay. But in safe mode that's not an option
so you can use this method
 
@AlmaDo Who said anything about safe mode?
This runs on my VPS
 
7:06 AM
moin
 
@AlmaDo sleep doesn't work in a safe mode? :-S
 
it works
 
Morning @JoeWatkins
Hope you had a better start to this day then yesterday
 
not bad ... we overslept ... so late, but not bad ;)
 
7:18 AM
@bwoebi rewriting it ^^
 
hehe. Interesting result
why if I throw an exception inside tick function, it can not be caught? (so even if I'm doing registering tick function inside try {} .. block ? )
minimal code to reproduce:
declare(ticks=1);
try
{
    register_tick_function(function()
    {
        throw new Exception('Trap!');
    });
}
catch (Exception $e)
{
   echo('Caught!');
}
 
@SecondRikudo as a side note, I had problems making scripts limited by php time limits being atomic, that is, making them exit in the middle of the cycle
 
will result it thrown exception
 
@AlmaDo does it work if you add another statement after the register tick fn?
 
7:28 AM
@NikiC no. If I do
register_tick_function(function()
    {
        echo('I am here'.PHP_EOL);
        throw new Exception('Trap!');
    });
I see
$ php empty.php
I am here
Caught!I am here

Fatal error: Uncaught exception 'Exception' with message 'Trap!' in /empty.php:8
Stack trace:
I know it's mad thing to do it, but I'm just curious
so why it works & does not works with it ?
hm.. it seems it throws exception in catch block when I do echo ..
because it's also a tick
 
@AlmaDo I mean another statement in the try {}
@AlmaDo that looks like it does throw the exception and you catch it, no?
 
@NikiC I think I got it. catch is also a tick, isn't it? if so, it will do: raise exception inside try block. then. caught it and proceed to catch block. But catch is also a tick, so it will again trigger that exception from inside tick function
that's why it isn't a good idea after all
 
always wondered what are the use cases of registering ticks outside of debugging?
 
@SergeyTelshevsky there is..
14
Q: Benchmark memory usage in PHP

Alma DoSO, Specifics Let us suppose that we have some problem and at least two solutions for it. And what we want to achieve - is to compare effectiveness for them. How to do this? Obviously, the best answer is: do tests. And I doubt there's a better way when it comes to language-specific questions (f...

 
can you provide an example?
 
7:37 AM
I've written benchmark. Better to use profiler, but this will also work for relative tests
 
yeah, and outside of that?
 
doubt. They may be, but I can't remember
 
can you recommend some ready tool for watching variables using that function or should I do it myself?
would be nice to register some var to be monitored for all changes
 
@SergeyTelshevsky use phpdbg
really, it's the task for debugger
 
@AlmaDo not possible, I'm on 5.3 and can't upgrade
 
7:43 AM
I didn't know, but it has nice gdb-like style. I really recommend it
 
yes, I do use it on my side projects
 
well, how will you "monitor" your variable? Log? huh.. sounds weird..
 
yes, sometimes I really miss that functionality, when some magic bug appears
putting a reference to be monitored would be nice
 
but, you know that it's impossible in common case? tick function is a global thing while your variable may be just some local-scoped entity
 
shouldn't it be possible to monitor if it still exists by reference and drop monitoring if it's no more available? I never tried anything like that
 
7:52 AM
no. because it's about scopes. So either you'll be able to do that within one scope (hm.. global ?) or you'll keep some registry (I'm not sure yet - how). I may try to play with it a bit..
 
I'll try too
 
[off-topic] Weird when you listen again to a song you haven't played a long time.. it sound so different then expected.
 
Moonings
 
I've been using doctrine since yesterday and I've noticed the flush() method returns void, it does throw a Doctrine\ORM\OptimisticLockException so I assume that's if the unit of work fails? Seems very strange for the main method that starts off lots of important jobs just returns void === completely useless
 
8:12 AM
I think void is the best =]
 
I hope that's sarcasm
Am I just to assume that flush() will never fail or something
 
try making it fail
see what happens
I rarely use Doctrine, but I have no problem with functions returning nothing but "void"
 
no side effects and void return is yay in my book =]
 
But void tells me nothing. I'd be okay with a simple little function not returning anything but this flush() method goes off and does loads of crazy stuff and can at times be saving big collections to the database, there is plenty of room for an error along the way but yet it just returns void. I find this crazy
 
8:20 AM
good mornings
 
ThW
Morning
 
@David if there is an error, pretty sure there will be an exception. what do you want it to return? it is a command, not a query
 
morning all
 
@Patrick It throws \Doctrine\ORM\OptimisticLockException
@Patrick Do you just call flush() and not check if it succeeded? Seems to be how they do it in all the tutorials I've seen
 
yes
 
8:28 AM
This just doesn't seem correct to me
 
0
Q: Functions to escape CSS rules in PHP

Madara UchihaSome context I've been tasked with supplying an escaping function to arbitrary CSS values that are entered through a form. The goals and caveats are: I know it's bad practice to let users input CSS. Deal with it. Data will be injected either to a style attribute, or to an external stylesheet. ...

Anyone up for a review?
 
@David Did you read the link I posted?
 
mornings
 
o/ Chris
 
morning @DaveRandom
 
8:29 AM
moin
 
@Patrick I did. I'm just going to have to get used to calling flush() with maybe a catch (Exception $ex) because it seems to throw a wide range of exceptions not just the one it shows on the method doc Doctrine\ORM\OptimisticLockException
 
@David If it throws an exception you probably have a bug somewhere that you should fix?
 
@Patrick I haven't even called the flush() method yet. I'm looking through the method and the other methods it calls and they all throw exceptions so I have to prepare for them
 
8:33 AM
@SecondRikudo there's not much to review. The code is correct, small and quite readable.
 
@FlorianMargaine Cheers, could you post it there?
 
w.r.t. security, I don't think codereview is where you should ask for this kind of audit
 
@FlorianMargaine w.r.t.?
With Respect To?
 
@David why? if you catch them, how will you see that there was a programming error?
 
@SecondRikudo Holy crap, there are servers that still exist running 5.1?
 
8:38 AM
@SecondRikudo s/respect/regards
 
@Patrick If they throw an exception I want to gracefully deal with it I don't want the whole program to crash
 
@DaveRandom Sadly, ours.
It's uber legacy and is in the process of being replaced to Java code.
 
@DaveRandom there are servers that still running 5.0.x
 
it's actually illegal to use 5.1
 
^ so how about to use 5.0 ?
 
8:39 AM
@Patrick Can the entity manager create new instances of an entity, with no data in it or do you just have to make your own entity factory?
 
@David as far as I know you need to use the new call or use a factory. I really dislike that
 
@Patrick This entity manager does a million things you don't need but then can't give you back a blank entity
 
@AlmaDo there's no such thing as 5.0
 
@JoeWatkins Illegal where?
 
@JoeWatkins ORLY? :D
 
8:42 AM
@SecondRikudo everywhere, crimes against humanity ...
 
@JoeWatkins 3v4l tests with 5.0.0, what do you call that?
@JoeWatkins Agreed.
 
I guess then using PHP is crime against humanity :p
 
@AlmaDo @FlorianMargaine would agree.
 
damn this coffe is good
 
@SecondRikudo deep inside our hearts.. we all agree. But .. well, you've got the idea :p
 
8:44 AM
@AlmaDo HARTS
 
Make int, not var
 
@SecondRikudo E_FIXED
 
@SergeyTelshevsky make install
 
no using php is okay, so long as it's a decent version ... 5.1 is 8 years old ... I wouldn't touch it with a shitty stick ...
 
who cares?
 
8:45 AM
@SecondRikudo using JS is a crime against humanity, too.
 
@SecondRikudo :)
 
obviously not you ...
 
Lisp is the only true language.
 
doesn't make it less stupid to use unsupported, extremely out of date software tho ...
 
@AlmaDo That is literally unbelievable. I actually do not believe it. No-one would do that to themselves.
 
8:46 AM
@FlorianMargaine lisp sucks. use asm
 
5.0 was, incredibly, even more broken that 4.x
 
guys... I worked with 4.x servers last year
 
@DaveRandom one of our prod. servers still runs php 5.0
 
<head explodes>
 
yeah, get new sysadmin, your current ones suck so damn hard ...
 
8:47 AM
fortunately, I have nothing to do with it
 
@FlorianMargaine I still occasionally write code for 4.3.10 and I have written code for 5.0.x, that is how I know with confidence 5.0.x is worse
 
so I wonder
if using 5.1 is illegal, how can we call using of 5.0
 
4.3 is like working where someone shot you in the kneecaps, 5.0 is like someone bandaged your kneecaps, told you it wouldn't happen again and then shot you in the back as you crawled away
 
^ but she's happy. I doubt using 5.0 produces happiness
 
8:50 AM
@DaveRandom How could you walk with shot kneecaps?
@AlmaDo She's happy to exterminate everyone
 
fine, be like that :-P
 
9:01 AM
hi guys how long does google take roughly to add your website to their search engine after submission?
 
42
 
hours?
 
next
 
9:02 AM
42
 
@DaveRandom Ow new ones. Noice!
 
it's room 11, baby
(:
 
Morning room 11
 
morning
 
Booooo no kim bauer :(
 
9:04 AM
@PeeHaa oh, so you're baby ? yay :D
 
next
 
@AlmaDo ? :P
 
E_JOKE_FAIL
 
:P
Finally a probably fair profile bio!
 
9:06 AM
where?
 
> PHP intermediate programmer cc @GotalovePHP
 
what does it mean "intermediate" ?
 
mines fair ...
 
@AlmaDo Between junior and senior I would say
 
@JoeWatkins 42 hours?
 
9:07 AM
@PeeHaa oh, so that's about me
 
@PeeHaa what of it?
@AlmaDo google
 
the answer to all unanswerable questions, including but not limited to "what is the meaning of life" is 42.
 
@GotalovePHP google?
 
@AlmaDo That's about 99% of people who say they are senior / engineer / awesomesauce in their bio
@GotalovePHP Honest profile is honest. Most people will say they are uber awesome and KNOWS ALL THE THINGS!
 
@PeeHaa I'm not saying that (: since I'm not good as senior should be
 
9:09 AM
/me updates profile with Senior Awesome Sauce Engineer
 
:P
 
@JoeWatkins why? You can just type two words there
pthreads and phpdbg
 
apcu
And it's already there ;)
 
yea put two words.. "Joe Watkins" .. hehe
 
9:12 AM
Oh thanks @JoeWatkins I was actually confused why you were allechoing random numbers :-)
 
@PeeHaa I'm not entirely sure how accurate that info is. It's supposed to jump around a bit time wise, but so far (9 of supposedly 12 eps) it hasn't at all, and I'm now wondering if they've actually shot a full season and kept quiet about it.
 
Is it jack bauer like he used to be?
 
@AlmaDo I am honest am not entirely new to PHP but am not good enough to call myself a pro programmer so I went for intermediate(in-between)
@PeeHaa
 
@PeeHaa Yeh it's surprisingly good, IMO better than S8 (which I wasn't generally impressed with)
 
Awesome@!
@GotalovePHP Which is totally fair
 
9:18 AM
@PeeHaa I wonder is there a point, from which we can honestly count ourselves as "seniors" (so, "high" level). And, if yes, where is it..
 
@AlmaDo Imho seniors do less coding and more telling people what to do
 
@PeeHaa so if you have no team, you can't be "senior" even if your skill is godlike?
 
old people aren't on any kind of team ... they are senior ...
 
If you have no team there is no such title :)
Well there can be, but that's just for your cv :D
 
@PeeHaa well, I was about "level", not "title" (so replace "senior" to any other corresponding word which means high skill level)
 
9:22 AM
hey @iroegbu
 
I was just made PM for my group :|
 
6 afraid of 7
 
I have a git project on master. It has NO changes, it's in sync with github. I create a new local branch, and then it says I have changes to push in this new branch. What gives?
 
@PeeHaa 7 'ate' 9 :p
 
Nope because 7 is a registered six offender ;)
thank yahoo answer for that one :P
 
9:28 AM
@iroegbu prime minister ? prime mover ? public mascot ? persistent mincer ?
 
I like to think it is public mascot :D
 
hehe
hahahahaha
Threads in PHP are a joke btw. Even the multi-process support is delicate in my experience. The multi-process support in cURL isn't too shabby though, so that's what I'd like to use if possible. I think I'll take a closer look at Guzzle and implementation of Goutte. — quickshiftin yesterday
 
@JoeWatkins Where do you find these? Do you do regex for threads ready to defend :P
 
I search for pthreads, yeah ... because there's only three people (on the face of the earth, that I know of) that can really answer questions about it ...
 
And you killed the other two right? right
:-)
 
9:40 AM
@NikiC Uh, I thought of something smarter like starting these ob_buffers?
 
*guys
 
@DaveRandom Hey man, writing async stuff for TorrentPHP. As well as the async client that'll be required, do I also need to be passing in the Alert Reactor - or will it be the consuming class that will handle the reactor?
 
is there any simple way to substation from last value in array ?
$a = array(
    800,
    600,
    500
);
$d = 600;
Result : $a = array (800,500);
 
I don't understand the question @samitha
 
He want's to remove anything that matches a value from an array
 
9:49 AM
please consider the array $a
 
array_filter()
 
I see what the code does
 
and the $d = 600
 
array_pop
 
but the question doesn't make sense does it ?
 
9:50 AM
$result = array_filter($a, function($value) use ($d) { return $value !== $d; }
 
^ E_TOO_LONG
$result = array_diff($a, [$d]);
 
Haha, nice
 
@Jimbo i think you got it wrongly
 
Or, php 5.3... array_diff($a, array($d));
 
did you see the $a array and result array
?
$a = array(
    800,
    600,
    500
);
 
9:52 AM
@samitha Yes. You want: a - b basically, don't you?
 
i have a discount and it should be applying from end of the array @Jimbo
 
@PeeHaa fix it fix it fix it
 
woopsie
:)
 
@Jimbo what is this ?
$result = array_filter($a, function($value) use ($d) { return $value !== $d; }
 
9:54 AM
@samitha samita there are so many possible ways you can solve the task.
 
@samitha It will: (1) Loop the array (2) Return only values that != $d
 
@Jimbo i need to subtrack from a value from end of the array
$a = array(800,500,300);
 
Seriously have you really tried to solve it?
 
So: $a = array(800, 500, 300); $d = 300; $result = array(800, 500);
Is that what you want?
 
yes
 
9:56 AM
Ok
1: reverse the array (array_reverse())
2: foreach() around it
3: If you find `$d`, *unset it*
Then break
 
$a = array(
    800,
    600,
    500
);
$d = 600;
$r = array_reverse($a);

foreach ($r as $k => $v) {

    if ($d > $v) {

        $d = $d - $v;

        unset($r[$k]);

    } else {

        unset($r[$k]);

        $r[$k] = $v - $d;

    }

}

var_dump($r);
 
Sweet mother of god
 
See what i wrote @Jimbo
it have so many confusions
 

« first day (1353 days earlier)      last day (3600 days later) »