so i'm currently facing a strange behaviour in php, it might be something fairly easy to solve but I have been searching and looking my code for an 1h or 2, and i'm still stuck a the same place. Thanks for your help in advance.
So here is my problem
So I have this function
function extractZip($pathToZip, $pathToExtract){
$zip = new ZipArchive();
if ($zip->open($pathToZip) === true){
$zip->extractTo($pathToExtract);
$zip->close();
}
unlink($pathToZip);
}
And I use it with a zip built like this
/folder1/folder2/folder3/files
The problem is when I extract it as so
extractZip("path/to/zip.zip", "path/to/extract");
the structure becomes weird
/folder1/folder2/folder3/files -> this is fine
/folder2/folder3 -> this is weird because it recreates all the folders
and they are empty, but I don't want those useless folder!
Thank you and if something is not clear just ask questions
Upgrading php to the newest version corrected the problem, (php 5.6)
Related
I'm using the following library to give a update feature to my WordPress and this works fine with the code of documentation.
https://github.com/YahnisElsts/plugin-update-checker/blob/master/README.md
require 'plugin-update-checker/plugin-update-checker.php';
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://github.com/user-name/repo-name/',
__FILE__,
'unique-plugin-or-theme-slug'
);
But I'm really wondering where this '$myUpdateChecker' variable came from and how this is working, because I can't find any part of the library's files using this variable.
It seems to be totally independent for me.
Thank you in advance.
You're creating the variable right there. You can even name it something else if you want (eg. $update_checker), that shouldn't cause any issues in this particular case as the variable isn't being used anywhere else (according to your own words.)
For more details: PHP variables.
So when I create a new Laravel project, gulp watch worked very perfectly. Now I'm working on PyroCMS project which is also used Laravel and the gulp watch kinda fails. I don't know why.
It seems to have a problem with watching multiple sass files at the same time. It does not watch at all. However, with one sass file, it works perfectly.
Here is my code:
var sassPath = './addons/dscms/anomaly/generali-theme/resources/sass/',
cssPath = './addons/dscms/anomaly/generali-theme/resources/css/',
jsPath = './addons/dscms/anomaly/generali-theme/resources/js/',
jsCopyPath = './addons/dscms/anomaly/generali-theme/resources/js/my-js/';
elixir(mix => {
mix
.sass([
''+sassPath+'main-style.sass',
''+sassPath+'section1.sass',
''+sassPath+'section2.sass'
], ''+cssPath+'main.css')
.scripts([
''+jsPath+'main.js',
''+jsPath+'main-2.js',
''+jsPath+'main-3.js'
],''+jsCopyPath+'main.js');
});
It also work with multiple js files but not sass files. Please help me with this one. Thank you very much!
I'm sorry for that. That was completely my fault :) The syntax was a little bit wrong there. The correct code is like this
mix
.sass(''+sassPath+'*.*', ''+cssPath+'main.css')
and I tested it. It watched multiple files and concatenated into one file. Worked perfectly!
I want to get file headers for compare i.e
if (file_header == image)
{
//do something
}
but I can't figure out how to do it...
I was looking mime-content-type, but it is not working for me... then finfo-file doenot work because I have only php 5.2 version... So can anyone help me with my problem?
UPD1 also I can't use fileinfo()
So I solved my problem with deleting one extra check and all is working now!
I am looking at someones project and keep getting this line:
$resource_folder = getScenarioResourceFolder(getScenarioPath($scenario));
I cannot find any function that he implemented under those two names - getScenarioResourceFolder and getScenarioPath.
I started wandering that maybe the name Scenario has something to do with $scenario variable being in those functions. I know it might sound dumb, but I do not know what else to think.
Does anyone know about these function?
I know these:
You can search the function:
http://id1.php.net/manual-lookup.php?pattern=getScenarioPath if no
result, That is must be user-defined function.
You can check yourself by using
if (function_exists('getScenarioPath')) {
...
} else {
...
}
These are clearly custom functions that have been written in.
The simplest solution would be to GREP your entire system for getScenarioResourceFolder - you are looking for a .php file.
If you can't grep or don't know how, then it's time to go digging. Open any PHP files that are related to that project and look for getScenarioResourceFolder().
If you really don't have it, then you'll have to get in touch with the original architect of the project.
I apologize if this has been answered, but I haven't been able to find anything about it. I've been having trouble with a certain block of PHP code on my server and have finally realized that it doesn't like single line comments. With this code, the method get_all_articles is never called.
<?php
$article_class = new Articles();
// Fetch all articles
$articles = $article_class->get_all_articles();
?>
However, removing the comment or converting it to a block comment allows the page to render perfectly. I realize that I've already figured out what's causing the problem, but what I'm looking for is why or how I might be able to fix it. Any help would be greatly appreciated. Thanks!
Maybe the formatting is getting lost on upload to where line breaks are being deleted? Try downloading the PHP file after you've uploaded it and see if the line breaks are still intact.
This can be frustrating... One time I had an if statement that would ALWAYS execute, no matter what the values were...
Started out as this, where $x was equal to 5 (I verified this with debugging)
if($x > 10);
{
....
}
Eventually, I had it down to this:
if(false);
{
echo("This should never happen");
echo("but it does!!!!!!!");
}
After much loss of hair, I realized that I had a semi-colon at the end of the if() line, therefore translating into:
if(false)
/*do nothing*/;
{
//Nice block that always executes
}
The moral of this story is that while the problem you percieve is actually giving you a problem, it is not a PHP problem. Try to find out the root cause by first verifying that the actual code that is executing is EXACTLY what you typed. Re-download the file, publish with different protocol, publish as binary, check sha1sum() on files to make sure the same... Look and look and you will find it.
Let us know.