Hi,
I'm using php to delete, rename, copy... some files. Sometimes php has
no permissions to do these operations, so the unlink(), rename(),
copy(), ... methods return a warning and send it to the browser.
What I'd like to do is to get these warning messages and save them in a
variable to print them somewhere else later so that it look nicer.
With the @ before the methods I can ignore warnings/errors but that's
not exactly what I want.
For example, when mysql returns an error, I can get it with the
mysql_error() method.
Has anyone an idea, how could I do this?
Thanks
Yeray 2 33837
Yeray Garcia wrote: I'm using php to delete, rename, copy... some files. Sometimes php has no permissions to do these operations, so the unlink(), rename(), copy(), ... methods return a warning and send it to the browser.
What I'd like to do is to get these warning messages and save them in a variable to print them somewhere else later so that it look nicer.
With the @ before the methods I can ignore warnings/errors but that's not exactly what I want.
For example, when mysql returns an error, I can get it with the mysql_error() method.
Has anyone an idea, how could I do this?
========
<?php
$old_track = ini_set('track_errors', '1');
if (!@unlink('no_file')) {
echo $php_errormsg, "\n";
}
if (!@copy('no_file', 'some_file')) {
echo $php_errormsg, "\n";
}
ini_set('track_errors', $old_track);
?>
========
And the output is:
No such file or directory
failed to open stream: No such file or directory
See http://www.php.net/manual/en/ref.errorfunc.php
--
USENET would be a better place if everybody read: : mail address : http://www.catb.org/~esr/faqs/smart-questions.html : is valid for : http://www.netmeister.org/news/learn2quote2.html : "text/plain" : http://www.expita.com/nomime.html : to 10K bytes :
That is exactly what I was looking for.
Thanks a lot.
Yeray
Pedro Graca wrote: Yeray Garcia wrote:
I'm using php to delete, rename, copy... some files. Sometimes php has no permissions to do these operations, so the unlink(), rename(), copy(), ... methods return a warning and send it to the browser.
What I'd like to do is to get these warning messages and save them in a variable to print them somewhere else later so that it look nicer.
With the @ before the methods I can ignore warnings/errors but that's not exactly what I want.
For example, when mysql returns an error, I can get it with the mysql_error() method.
Has anyone an idea, how could I do this?
======== <?php
$old_track = ini_set('track_errors', '1');
if (!@unlink('no_file')) { echo $php_errormsg, "\n"; }
if (!@copy('no_file', 'some_file')) { echo $php_errormsg, "\n"; }
ini_set('track_errors', $old_track);
?> ========
And the output is:
No such file or directory failed to open stream: No such file or directory
See http://www.php.net/manual/en/ref.errorfunc.php
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gianni Mariani |
last post by:
I have a couple of template methods that take any integer type however,
the first "if" statement becomes a constant expression when T is an
unsigned type.
#include <limits>
template...
|
by: Ivan Shevanski |
last post by:
Here's a noob question for everyone (I'm not sure if my first message got
through, is had a "suspicious header" so sorry for double post is so), is
there a way to turn off syntax warnings or just...
|
by: Samuel |
last post by:
Imagine you have the following code:
try
{
...
}
catch (ThreadAbortException eThread)
{
if (WorkStopped != null) WorkStopped(this, EventArgs.Empty)
}
|
by: Steve |
last post by:
I have some general catch clauses in my app as follows:
try
{
}
catch(Exception ex)
{
}
try
|
by: Bob |
last post by:
Hi,
The compiler gives Warning 96 Variable 'cmdSource' is used before it has
been assigned a value. A null reference exception could result at runtime.
Dim cmdSource as SQlClient.SQLDataReader...
|
by: sbalak |
last post by:
I am writing code in C# and I wanted a basic solution:
In Try / Catch block, I want to get a general Exception. So, I write
code as:
try
{
// do something
}
catch (SomethingException ex)
{
|
by: aioe.cjb.net |
last post by:
So, I was planning on ridding my VS2005 solution of all warnings, but the
ones sounding "The variable 'ex' is declared but never used" in
catch-blocks, are causing a headache.
I have several...
|
by: Sergei Shelukhin |
last post by:
Hi.
I need to handle warnings in incorrect regular expressions executed
using preg_match.
Warnings shouldn't appear, instead I want to output some generic
message like: "Bad regex: $regex" and...
|
by: RP |
last post by:
In certain code blocks I don't want to do anything when an error is
raised. I simply want that application must remain stable instead of
crash. For the following code, is there a way to ignore...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |