How can i get error in php?
This always works for me: Show
However, this doesn't make PHP to show parse errors - the only way to show those errors is to modify your php.ini with this line:
(if you
don't have access to
anthonyryan1 4,5182 gold badges33 silver badges27 bronze badges answered Jan 29, 2014 at 11:25
Fancy JohnFancy John 37k3 gold badges25 silver badges25 bronze badges 18 You can't catch parse errors when enabling error output at runtime, because it parses the file before actually executing anything (and since it encounters an error during this, it won't execute anything). You'll need to change the actual server configuration so that display_errors is on and the approriate error_reporting level is used. If you don't have access to php.ini, you may be able to use .htaccess or similar, depending on the server. This question may provide additional info.
answered Jun 27, 2009 at 19:14
Michael MadsenMichael Madsen 53.3k7 gold badges71 silver badges82 bronze badges 0 Inside your php.ini:
Then restart your web server.
j0k 22.3k28 gold badges77 silver badges86 bronze badges answered Jan 8, 2013 at 9:27
user1803477user1803477 1,5651 gold badge9 silver badges4 bronze badges 5 To display all errors you need to: 1. Have these lines in the PHP script you're calling from the browser (typically
2.(a) Make sure that this script has no syntax errors —or— 2.(b) Set Otherwise, it can't even run those 2 lines! You can check for syntax errors in your script by running (at the command line):
If you include the script from another PHP script then it will display syntax errors in the included script. For example:
answered Jan 29, 2014 at 9:52
andreandre 1,8011 gold badge15 silver badges8 bronze badges 2 Some web hosting providers allow you to change PHP parameters in the You can add the following line:
I had the same issue as yours and this solution fixed it.
answered May 18, 2013 at 15:01
KalhuaKalhua 5514 silver badges2 bronze badges 1 You might find all of the settings for "error reporting" or "display errors" do not appear to work in PHP 7. That is because error handling has changed. Try this instead:
Or, to catch exceptions and errors in one go (this is not backward compatible with PHP 5):
answered Mar 28, 2016 at 19:26
Frank ForteFrank Forte 1,83717 silver badges18 bronze badges 9 This will work:
answered May 5, 2014 at 13:23
Mahendra JellaMahendra Jella 5,1501 gold badge31 silver badges38 bronze badges 1 Use:
This is the best way to write it, but a syntax error gives blank output, so use the console to check for syntax errors. The best way to debug PHP code is to use the console; run the following:
answered May 4, 2016 at 19:14
Abhijit JagtapAbhijit Jagtap 2,6352 gold badges31 silver badges43 bronze badges 0 Set this in your index.php file:
answered Sep 26, 2017 at 12:32
Sumit GuptaSumit Gupta 5694 silver badges12 bronze badges 0 Create a file called php.ini in the folder where your PHP file resides. Inside php.ini add the following code (I am giving an simple error showing code):
answered Mar 31, 2015 at 18:38
NavyaKumarNavyaKumar 5895 silver badges3 bronze badges As we are now running PHP 7, answers given here are not correct any more. The only one still OK is the one from Frank Forte, as he talks about PHP 7. On the other side, rather than trying to catch errors with a try/catch you can use a trick: use include. Here three pieces of code: File: tst1.php
Running this in PHP 7 will show nothing. Now, try this: File: tst2.php
File: tst3.php
Now run tst2 which sets the error reporting, and then include tst3. You will see:
answered May 20, 2017 at 12:07
PeterPeter 1,12815 silver badges32 bronze badges 1 I would usually go with the following code in my plain PHP projects.
answered Feb 1, 2017 at 7:16
If, despite following all of the above answers (or you can't edit your php.ini file), you still can't get an error message, try making a new PHP file that enables error reporting and then include the problem file. eg:
Despite having everything set properly in my
answered Apr 24, 2015 at 2:55
jxmallettjxmallett 3,9771 gold badge27 silver badges35 bronze badges 2 If you somehow find yourself in a situation where you can't modifiy the setting via
If your host is so locked down that it does not allow changing the value via
answered Jan 11, 2016 at 12:11
chiborgchiborg 25.6k12 gold badges97 silver badges113 bronze badges 1 You can do something like below: Set the below parameters in your main index file:
Then based on your requirement you can choose which you want to show: For all errors, warnings and notices:
For all errors:
For all warnings:
For all notices:
For more information, check here.
answered Feb 1, 2017 at 7:33
Binit GhetiyaBinit Ghetiya 1,8192 gold badges22 silver badges31 bronze badges 1 You can add your own custom error handler, which can provide extra debug information. Furthermore, you can set it up to send you the information via email.
answered Jun 4, 2017 at 14:41
lintabálintabá 7219 silver badges18 bronze badges Accepted asnwer including extra options. In PHP files for in my DEVELOPMENT apache vhost (.htaccess if you can ensure it doesn't get into production):
However, this doesn't make PHP to show parse errors - the only way to show those errors is to modify your php.ini with this line:
(if you don't have access to
answered Jan 8 at 22:17
This code on top should work:
However, try to edit the code on the phone in the file:
answered May 9, 2017 at 3:28
Joel WemboJoel Wembo 7775 silver badges10 bronze badges The best/easy/fast solution that you can use if it's a quick debugging, is to surround your code with catching exceptions. That's what I'm doing when I want to check something fast in production.
answered Mar 27, 2017 at 2:31
XakiruXakiru 2,2711 gold badge14 silver badges11 bronze badges 1
While your site is live, the
answered May 24, 2018 at 8:48
pardeeppardeep 3311 gold badge5 silver badges7 bronze badges 0 Just write:
answered Jan 13, 2017 at 18:56
jewelhuqjewelhuq 1,16413 silver badges19 bronze badges 0 You can do this by changing the php.ini file and add the following
OR you can also use the following code as this always works for me
answered Apr 11, 2019 at 8:43
0 If you have Xdebug installed you can override every setting by setting:
answered Oct 19, 2017 at 5:45
You might want to use this code:
baduker 15.9k9 gold badges27 silver badges47 bronze badges answered Mar 28, 2019 at 12:42 Report all errors except E_NOTICE
Display all PHP errors
Turn off all error reporting
answered Dec 31, 2019 at 10:07
If it is on the command line, you can run
answered Oct 24, 2019 at 23:11
gvlasovgvlasov 17.1k19 gold badges66 silver badges104 bronze badges
Put this at the top of your page. answered Feb 28, 2021 at 0:51
KwedKwed 2012 silver badges4 bronze badges Input this on the top of your code
And in the php.ini file, insert this:
This must work. answered Aug 23, 2021 at 21:22
You can show Php error in your display via simple ways. Firstly, just put this below code in your php.ini file.
(if you don't have access to php.ini, then putting this line in .htaccess might work too):
OR you can also use the following code in your index.php file
answered Nov 6, 2020 at 6:41
In Unix CLI, it's very practical to redirect only errors to a file:
From your script, either use
Then from another shell, for live changes:
or simply
answered Nov 26, 2019 at 2:28
NVRMNVRM 9,5991 gold badge74 silver badges82 bronze badges 2 How do I view PHP error logs?Look for the entry Configuration File (php.
Find the Error handling and logging section of the php. ini file. Make sure that both display_errors = On, display_startup_errors = On and log_errors = On are present and uncommented. Check the value of error_log - this tells you the location of the file errors are logged to.
How can I get 500 error in PHP?You can solve the PHP error 500 by temporarily deleting the misconfigured htaccess file. The 500 error can go away by increasing the values set for the max_execution_time and the memory_limit settings. Setting the file permission to 644 or 755 can help in resolving the 500 internal server error.
How do I fix PHP errors?Editing the php.. Log into your cPanel.. Go to the File Manager. ... . Find the “Error handling and logging” section in the php.ini. ... . Next you can set the display_errors variable to On or Off to either show the errors on your website or not.. What is PHP report error?The error_reporting() function specifies which errors are reported. PHP has many levels of errors, and using this function sets that level for the current script.
|