I know this must be a nooby question and I apologize but I can't find a straight forward answer anywhere!
Basically what I want to do is, if someone visits http://domain.co.uk/?debug then I want it to display additional information such as the code version or any other information I enter.
Again, I am sorry for the question but I really appreciate your help!
Thank you.
if (isset($_GET['debug'])) {
echo "Get the raid! There's bugs!";
}
As Hope4You pointed out, this is bad practice. But somehow this is very useful when deploying our application. One trick is to set up a "in development" flag.
<?php
define('DEVELOPMENT_SERVER', TRUE);
if (DEVELOPMENT_SERVER)
require 'debug_tools.php';
where debug_tools.php contains the code from MarcB and other helper functions.
Related
Currently I'm having problems with rowClone and blockClone specially. In the documentation they says that if we use rowClone over a table with merged cells, the function (rowClone) will clone the adjacents rows, so I said, ok well, it looks pretty nice. So I made a table as you can see in the image 1, but when I execute the script, the function rowClone doesn't work as I was expecting.
Then reading the documentation deeper, I realized that there is another function called blockClone, but when I tried to use it, surprise, it doesn't work neither.
Finally I started looking for solutions on the Internet, but nothing they proposes help me, so please if you have any advice, hack, anything, please comment. Thanks in advance.
Image 1: template (.docx)
Image 2: result after processing the template
I found the bug in the source code. There is a space in a regular expression that made function preg_match does not match anything. Following I show you how to fix it:
This is the original code:
if (!preg_match('#<w:vMerge/>#', $tmpXmlRow) &&
!preg_match('#<w:vMerge w:val="continue" />#', $tmpXmlRow)) {
break;
}
And this te code fixed.
if (!preg_match('#<w:vMerge/>#', $tmpXmlRow) &&
!preg_match('#<w:vMerge w:val="continue"/>#', $tmpXmlRow)) {
break;
}
The above if is between 298 and 302 in the source code (https://github.com/PHPOffice/PHPWord/blob/develop/src/PhpWord/TemplateProcessor.php)
I have hope it could help you!
I have a little problem, I want to do accesible my webpage(with Moodle), I used http://jigsaw.w3.org/css-validator/ and I have a lot of errors, the uri is on: theme/yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.css but I don't found it.
I look it the file(yui_combo.php) but I dont found anything, can anyone help me? thanks
Ok this file is generated automatically from files:
--versionyui--/widget-base/assets/skins/sam/widget-base.css
--versionyui--/widget-stack/assets/skins/sam/widget-stack.css
--versionyui--/overlay/assets/skins/sam/overlay.css
--versionyui--/widget-modality/assets/skins/sam/widget-modality.css
--versionyui--/panel/assets/skins/sam/panel.css
At least in my case
I need to take all the files in the folder where the PHP file is, dump them together, and echo them. What is the simplest way to do it?
For example, I have the following files:
ILikeFish.txt
I like fish please bring me fish!
Well that's enough don't bring me anymore.
ILikePotatos.js
var Potatos = {yummy:true, amount:5323.6}
function potatoFunc(stuff) {
while (stuff=="cool") moreStuff();
}
Dawgz.png
Picture of a dog
Well, I want the output to be:
(.txt ignored)
var Potatos = {yummy:true, amount:5323.6}
function potatoFunc(stuff) {
while (stuff=="cool") moreStuff();
}
(Picture ignored)
How can I do it? Thanks for answering!
Also, I'm VERY basic in PHP and I know nothing, so please forgive me if this question is super dumb. Also, I AM aware of this question, but it doesn't answer how to do it!
Also, my final goal is to include all my libraries and comments using one line of
<script src="http://MySite/AllJsses.php"></script>
And again, Thanks for taking the time and answering!!!
Okay, after playing a little with google, w3schools and my genius brain I came up with the following:
<?php
$files = glob("*.js");
for ($i = 0; $i < count($files); $i++) {
echo file_get_contents($files[$i]);
}
?>
Thanks to myself and to some guy on other forums for answering this question! :D
Also, if any of you find any errors / performance issues / anything, please comment, because otherwise host gonna kill me. Thank you!
I started learning this very nice PHP ORM api last week: http://phpdatamapper.com/
and have been trying to get up to speed with it
What I'm not seeing in the site documentation, is how to iterate with "$postMapper->all()"?
http://phpdatamapper.com/documentation/usage/finders/
When I try to iterate through the value returned from ->all(), it seems only to have gotten the last element in the table.
Here's the code I have:
// $postMapper uses phpDataMapper framework. It works to create the schema & insert values
$postEntities = $postMapper->all();
$postEntities->execute(); // tried adding this to help things
foreach ( $postEntities as $postEntity);
{
echo $postEntity->title;
echo "<br/>";
}
I see other folks are forking it from GitHub and using it in their projects, so I believe I'm making some mistake in my call logic.
It would be great if someone could share a small example of how to access the query data correctly when using mapper->all()? This is an important part of a PHP stack and I would very much like to be able to use this particular solution in my projects going forward. Thanks
Ok, this turned out to be a "not so smart" mistake on my part. The font in my IDE was too small I guess, and I didn't see the ';' at the end of the line that declares the for loop.
So the ORM is all good, just my code wasn't. I'm updating this in case someone else can learn from my mistake - other option is to just delete the post all together (... not sure which is better)
I have link:
http://www.facebook.com/sharer.php?u=http://xxx.xxx.xxx.xxx/~user/file.php
and I want to make it look like this:
http://www.facebook.com/sharer.php?u=http://MyUrl.com/file.php
Essentially I want to replace "xxx.xxx.xxx.xxx/~user" with "MyUrl.com"
Thank you so much for taking the time to help!
One more thing. The file name "file.php" part changes for each page. I don not know ahead what the exact page name will be. Ideally I am wanting to use the php script as an include that will be on every page. I hope this helps clear things up.
where's the problem with this?
http://php.net/manual/fr/function.str-replace.php
$newURL = str_replace("xxx.xxx.xxx.xxx/~user","MyUrl.com","http://www.facebook.com/sharer.php?u=http://xxx.xxx.xxx.xxx/~user/file.php");
UPDATED QUESTION :
you want to swich the xxx.xxx.xxx.xxx/~user AND the file.php
sorry but at this point why don't you just do
http://www.facebook.com/sharer.php?u=http://".$_SERVER['HTTP_HOST']."/".$filename