|
After several online searches, I couldn't find an answer to this. When I do this: code:
code:
code:
e: fixed it by changing it to get rid of the echo, but an explanation of the 1 would still be appreciated. Master_Odin fucked around with this message at 19:20 on Jul 3, 2010 |
# ¿ Jul 3, 2010 19:11 |
|
|
# ¿ May 15, 2024 13:23 |
|
So recently, an old client contacted me today saying that he hosed up an upload script I wrote a while ago that used the APC library to create an upload bar. He apparently managed to delete APC from the server among other things. Anyway, managed to get it installed (or at least it looks installed), yet the bar isn't working and I'm not sure as it was about 2 and 1/2 years ago that I wrote this and I honestly don't remember the APC library well enough to actually debug this and it's pretty mission critical. Hopefully you goons can help me. My scripts: http://pastebin.com/vd4T0zHF (index html) http://pastebin.com/FHMWPxiZ (getprogress.php) http://pastebin.com/XW0Msvk0 (apc settings)
|
# ¿ Jul 21, 2011 07:55 |
|
McGlockenshire posted:The code looks correct at first glance. Warning: session_start() [function.session-start]: open(/tmp/sess_8e01f9802198750c4bc92fa1c8c7c24a, O_RDWR) failed: Permission denied (13) in /home/client/public_html/xsuploader/index.php on line 2 I set /tmp in the linux root to 777 as well as the tmp in /home/client yet I'm still getting that error. It showed up when I set the PHP configuration to use DSO instead of SuPHP. Turning suExec on/off didn't seem to make a difference. Is there another easy upload bar that I could use as it seems like installing APC has become a headache in and of itself. e: on Chrome I get 0% before it successfully uploads and on firefox I get 1% before it uploads successfully on a 8mb upload. Master_Odin fucked around with this message at 17:46 on Jul 21, 2011 |
# ¿ Jul 21, 2011 17:19 |
|
McGlockenshire posted:Just to hone in on the APC issue, suPHP runs PHP as a CGI, not under mod_php. e: I'm probably just going to relay this stuff to my client and tell him to contact his server provider to deal with this because gently caress trying to figure this poo poo out as I don't want to try and learn how to use/manage a server like this. Master_Odin fucked around with this message at 04:08 on Jul 22, 2011 |
# ¿ Jul 22, 2011 03:20 |
|
Alternatively, you can use array_splice. The primary downside is that you have to run a final splice outside the loop to pick up the final group.php:<? $groups = array(); $check = 0; $last = 0; $count = 0; foreach($a as $k => $v) { $check += $v; if ($check >= 100) { $groups[] = array_slice($a,$last,($count-$last)); $last = $count; $check = $v; } $count++; } $groups[] = array_slice($a,$last,($count-$last)); ?>
|
# ¿ Jun 26, 2013 20:10 |
|
Vedder posted:That's exactly what I need and thank you for introducing me to PDO, just read a couple of tutorials and I will have a go later. I always find PHP is one of those languages where some people work completely different to other people. Sometimes you will see a project that is a mixture of code and HTML, other times it's pure OO. If you're set on getting a book, I'd only look for one that goes into design paradigms (like when/how to use singleton classes, factories, etc.) as that's a bit harder to pickup than language features. Master_Odin fucked around with this message at 16:13 on Jul 29, 2013 |
# ¿ Jul 29, 2013 08:22 |
|
You want to use pagination or something where you havecode:
You'd also want to use 'a' in the fopen if using the same file.
|
# ¿ Jan 31, 2015 18:13 |
|
revmoo posted:I've never seen a use case of switch() where I thought it made sense. At best you're abbreviating what should be a function or class, depending on complexity, and at worst you've written a bunch of lovely if statements that could have been done a smarter way. The last switch statement I wrote was given a database info object, open an appropriate table factory for it. I could have written code:
code:
|
# ¿ Mar 7, 2015 07:36 |
|
Jabor posted:If you litter your code with switch statements that check which database you're interacting with, adding another supported database is suddenly difficult because now you need to find and change every switch statement, if you're trying to track down a bug specific to one database implementation you need to track down every point at which the implementations diverge, etc.. A better way of implementing it is to have a dbInfo subclass for every database you're interacting with, that encapsulates all your database specific logic - the basic interface might have a method called getTableFactory that returns something that implements the TableFactory interface, where OracleDbInfo returns an OracleTableFactory from that method, PostgresDbInfo returns a PostgresTableFactory, etc.. Then when you need to add MySql support, all you need to do is write a new dbInfo subclass that implements the appropriate functionality. This is why polymorphism is generally preferred over switch statements. How about : code:
|
# ¿ Mar 7, 2015 16:39 |
|
revmoo posted:Oh, we're doing JS in the php thread now? It was actually Java, but you could apply the same ideas to PHP with constants: code:
|
# ¿ Mar 7, 2015 18:11 |
|
revmoo posted:This is the crux of the issue, you're making an aesthetic argument and that's going to boil down to personal preference. Personally I like being able to see 150+ conditionals on a single page of my coding monitor, and switch statements eat up line counts like crazy. http://stackoverflow.com/questions/395618/is-there-any-significant-difference-between-using-if-else-and-switch-case-in-c
|
# ¿ Mar 7, 2015 19:12 |
|
What's the best way to unit test a database driver class with phpunit? It uses PDO to connect to a database and then gives us utility functions to the underlying PDO class. Would I always want to hook this up to simple database and straight unit test this or is it generally better to mock the PDO class (and how? Pass in the PDO class to be used?) and then just mock out the necessary functions as necessary?
|
# ¿ Jul 7, 2016 17:23 |
|
You're probably looking for Doctrine.
|
# ¿ Mar 15, 2017 17:39 |
|
cheese-cube posted:Speaking of installing PHP, is the PPA from Ondřej Surư considered reputable: https://launchpad.net/~ondrej/+archive/ubuntu/php? I added it quite some time ago to get the latest PHP back when Ubuntu and Debian repos were lagging behind the times and its been pretty good I guess.
|
# ¿ Mar 13, 2018 16:08 |
|
The main problem here is the you're looking at the source code of the latest version of the Inflector which laravel does not use, which is why you can't find what the concrete WordInflector it's using. A quick look at it's composer.json reveals it has a ^1.1.0 dependency on the Inflector, so you could start there (or at 1.3, you'd have to look at the composer.lock file to get the exact version they're assuming). Looking at the 1.3 release (though I'm not fully sure it uses this, or an older version still, you'd have to check) should make more sense: https://github.com/doctrine/inflector/blob/1.3.x/lib/Doctrine/Common/Inflector/Inflector.php It should be noted that the new version of the Inflector that is being designed does not have static methods similar to the old version which would be a clue you weren't looking at the right code. Master_Odin fucked around with this message at 04:30 on Apr 12, 2019 |
# ¿ Apr 12, 2019 04:27 |
|
That's an IDE thing, PHP does not support named parameters unfortunately. PHPStorm refers to it as inlay hints.
|
# ¿ Feb 18, 2020 23:08 |
|
|
# ¿ May 15, 2024 13:23 |
|
22 Eargesplitten posted:Are there any major security issues with the latest version of PHP 7.0? I see that 7.2 exists, but I'm not sure if the current software I'm running will work with it, and I'd rather not risk breaking anything if there's no security issues. I can find security flaws doing a search on Google but I don't know which have been patched and which are still out there. https://github.com/PHPCompatibility/PHPCompatibility is a good library to help alleviate some of the pain of upgrading PHP versions.
|
# ¿ Jun 6, 2020 04:18 |