adspace


What is the use of @ in php?

Answer Posted / Mohit Dwivedi

The `@` symbol in PHP is used for error suppression. When prefixed to a function call, it suppresses any errors that might be thrown by that function. Here's an example:

```php
$file = '@/path/to/nonexistent_file.txt';
$contents = file_get_contents($file); // This will not throw an error if the file does not exist
echo $contents; // Output: null (empty string if using output buffering)
```
It's important to note that suppressing errors can make debugging more difficult, as you won't see the actual errors that occur. It should be used sparingly and with caution.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is trait in php?

1071


Write a program using while loop?

1125


if you run the app program all vendor open items are cleared but is it possible to reverse the again again open items please tell me the answer

1996


Tell me what kind of things have you done on the social side?

1069


how to detect a mobile device using php

1177


List some features of php that are deprecated in php7?

1026


hello all, I need some sample placement papers in lion bridge.. can anyone help me?

2181


Explain me is it possible to destroy a cookie?

1034


What is the current stable version of php?

1128


What does $_files means?

1168


What is difference between static and final in php?

1112


sort term descripttion form, report and uery

2257


How to create a web form?

1116


What is the difference between htmlentities() and htmlspecialchars()?

1097


What sized websites have you worked on in the past?

1090