Skip to content

Tag: php

Passing $_POST/$_GET as a parameter to function

I came across an interesting piece of PHP code which has me a bit stumped as to why the author has chosen to do this. It got me thinking about why someone would want to pass $_POST as a variable and just not access it directly inside the function? The only benefit I could think of (and this was a

PHP Mocking Final Class

I am attempting to mock a php final class but since it is declared final I keep receiving this error: PHPUnit_Framework_Exception: Class “DoctrineORMQuery” is declared “final” and cannot be mocked. Is there anyway to get around this final behavior just for my unit tests without introdu…

Pushing a sub array into the same array

I am trying to put content of one array into the same array. Here I have an array $mclass with values such as You can see I have room_id index with 1,3,5 value. Now, I want to explode the room_id and get duplicate of same array index data with change of room_id and push into the array. and finally delete

How to copy very large files from URL to server via PHP?

I use the following code to copy/download files from an external server (any server via a URL) to my hosted web server(Dreamhost shared hosting at default settings). However the function stops running at about once 2.5GB (sometimes 2.3GB and sometimes 2.7GB, etc) of the file has downloaded. This happens every…

get uploaded file size in bytes in php

I am uploading a file which is an image. I want to get the size of that image every time in bytes only using PHP. I had done this by far $name=$_FILES[‘image’][‘name’]; if($name!=null) { $tmpDest=…

Working directly with libraries instead of bundles in Symfony2

How can I use a library directly inside an existing Symfony2 project. I am, for instance, trying to add the faker library. I installed it via composer but I don’t know how and where to put the code I need. According to documentation: What is a simple explanation of auto loader? How to use a library dire…