Trending questions in PHP

0 votes
1 answer

How to pass an array via $_GET in php?

Hii, You can pass an associative array to http_build_query() and ...READ MORE

Nov 22, 2020 in PHP by Niroj
• 82,840 points
4,492 views
0 votes
1 answer

How to set a default attribute value for a Laravel / Eloquent model?

Hello @kartik, This is what I'm doing now: protected ...READ MORE

Nov 8, 2020 in PHP by Niroj
• 82,840 points
5,092 views
0 votes
1 answer

How foreach change original array values in php?

Hello @kartik, Do the following: foreach ($fields as $key ...READ MORE

Aug 14, 2020 in PHP by Niroj
• 82,840 points
8,752 views
0 votes
1 answer

How MySQL date format DD/MM/YYYY select query?

Hello @kartik, You can use STR_TO_DATE() to convert your strings ...READ MORE

Aug 26, 2020 in PHP by Niroj
• 82,840 points
8,201 views
0 votes
1 answer

How to check if memcache or memcached is installed for PHP?

Hii, You can look at phpinfo() or check ...READ MORE

Nov 6, 2020 in PHP by Niroj
• 82,840 points
4,997 views
0 votes
1 answer

How to remove a variable from a PHP session array?

Hello @kartik, Try: if (isset($_POST['remove'])) { ...READ MORE

Nov 8, 2020 in PHP by Niroj
• 82,840 points
4,868 views
0 votes
1 answer

How to delete object from array inside foreach loop?

Hello @kartik, Use this: foreach($array as $elementKey => $element) ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,840 points
7,183 views
0 votes
1 answer

How to check whether property exists in object or class in php?

Hello @kartik, Using  property_exists( mixed $class , string $property ...READ MORE

Oct 1, 2020 in PHP by Niroj
• 82,840 points
6,461 views
0 votes
1 answer

How can I explode and trim whitespace?

Hello @kartik, You can do the following using array_map: $new_arr ...READ MORE

Oct 1, 2020 in PHP by Niroj
• 82,840 points
6,357 views
0 votes
1 answer

How to convert a string to JSON object in PHP?

Hello @kartik, it seems that your JSON is ...READ MORE

Oct 20, 2020 in PHP by Niroj
• 82,840 points
5,518 views
0 votes
1 answer

PHP Warning Permission denied (13) on session_start()

Hello @kartik, You don't appear to have write ...READ MORE

Nov 17, 2020 in PHP by Niroj
• 82,840 points
4,251 views
0 votes
1 answer

How to show an alert box in PHP?

Hello, use this code echo '<script language="javascript">'; echo 'alert("message successfully ...READ MORE

Nov 4, 2020 in PHP by Niroj
• 82,840 points
4,787 views
0 votes
1 answer

Error:invalid address: @invalid@email You must provide at least one recipient email address.

Hello, PHPMailer uses Exceptions. Try the following code: require_once '../class.phpmailer.php'; $mail = new ...READ MORE

Nov 13, 2020 in PHP by Niroj
• 82,840 points
4,288 views
0 votes
1 answer

How do you set a default value for a MySQL Datetime column?

Hello @kartik, In version 5.6.5, it is possible ...READ MORE

Aug 18, 2020 in PHP by Niroj
• 82,840 points
8,027 views
0 votes
1 answer

How to allow duplicate keys in php array?

Hello @kartik, You could have a single key ...READ MORE

Nov 19, 2020 in PHP by Niroj
• 82,840 points
3,972 views
0 votes
1 answer

How to convert timestamp to date in MySQL query?

Hello @kartik, Try this: DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS ...READ MORE

Aug 19, 2020 in PHP by Niroj
• 82,840 points
7,899 views
0 votes
1 answer

How to import all classes from another namespace in PHP?

Hello @kartik, This is not possible in PHP. All ...READ MORE

Oct 20, 2020 in PHP by Niroj
• 82,840 points
5,199 views
0 votes
1 answer

How to write CSV To File Without Enclosures In PHP?

Hello @kartik, The warnings about foregoing enclosures are ...READ MORE

Nov 9, 2020 in PHP by Niroj
• 82,840 points
4,318 views
0 votes
1 answer

How can I ping a server port with PHP?

Hello @kartik, Test different ports: $wait = 1; // ...READ MORE

Nov 19, 2020 in PHP by Niroj
• 82,840 points
3,882 views
0 votes
1 answer

How to check if a string contains a specific text using php?

Hello @kartik, Use the strpos function:  $haystack = "foo bar baz"; $needle ...READ MORE

Nov 10, 2020 in PHP by Niroj
• 82,840 points
4,252 views
0 votes
1 answer

How to check if multiple array keys exists?

Hello @kartik, If you only have 2 keys ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,840 points
4,849 views
0 votes
1 answer

How do I remove a directory that is not empty?

Hello, Try this code: function rrmdir($dir) { if (is_dir($dir)) { ...READ MORE

Nov 4, 2020 in PHP by Niroj
• 82,840 points
4,484 views
0 votes
1 answer

How to Creat a folder when I run file_put_contents()?

Hello @kartik, file_put_contents() does not create the directory structure. ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,840 points
4,725 views
0 votes
1 answer

Fatal error: Call to undefined function mysql_connect()

Hello @kartik, You upgraded to PHP 7, and ...READ MORE

Nov 23, 2020 in PHP by Niroj
• 82,840 points
3,540 views
0 votes
1 answer

How to remove a child with a specific attribute, in SimpleXML for PHP?

Hii, Just unset the node: $str = <<<STR <a> ...READ MORE

Nov 5, 2020 in PHP by Niroj
• 82,840 points
4,323 views
0 votes
1 answer

How to pass arrays as url parameter?

Hello @kartik, There is a very simple solution: http_build_query(). ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,840 points
6,963 views
0 votes
1 answer

How to pass arguments to an included file?

Hello @kartik, Include has the scope of the ...READ MORE

Nov 20, 2020 in PHP by Niroj
• 82,840 points
3,451 views
0 votes
1 answer

How to get the home directory from a PHP CLI script?

Hello @kartik, You can fetch the value of ...READ MORE

Nov 3, 2020 in PHP by Niroj
• 82,840 points
4,161 views
0 votes
1 answer

How to post data in PHP using file_get_contents?

Hello @kartik, Sending an HTTP POST request using file_get_contents is ...READ MORE

Aug 24, 2020 in PHP by Niroj
• 82,840 points
7,212 views
0 votes
1 answer

How to check if a file exists from a url using php?

Hello, You have to use CURL function does_url_exists($url) { ...READ MORE

Nov 3, 2020 in PHP by Niroj
• 82,840 points
4,097 views
0 votes
1 answer

How to check if a string is an email address in PHP?

Hello, Try this without regular expressions: <?php ...READ MORE

Nov 3, 2020 in PHP by Niroj
• 82,840 points
3,980 views
0 votes
1 answer

How to display errors for my MySQLi query?

Hii, Use mysqli_error() As in: $sql = "Your SQL statement ...READ MORE

Nov 9, 2020 in PHP by Niroj
• 82,840 points
3,700 views
0 votes
1 answer

How to route GET and POST for same pattern in Laravel?

Hello @kartik, You could try the following: Route::controller('login','AuthController'); Then in ...READ MORE

Nov 22, 2020 in PHP by Niroj
• 82,840 points
3,114 views
0 votes
1 answer

How can I access Laravel .env variables in blade?

Hii @kartik, Try to implement this: @if (env('APP_ENV')!='Production') Enviroment Test @endif Hope ...READ MORE

Nov 10, 2020 in PHP by Niroj
• 82,840 points
3,572 views
0 votes
1 answer

How to echo a MySQLi prepared statement?

Hello @kartik, I don't think you can - ...READ MORE

Nov 14, 2020 in PHP by Niroj
• 82,840 points
3,403 views
0 votes
1 answer

How to check if row is soft-deleted in Eloquent?

Hello, Try this: if ($thing->trashed()) { ... } READ MORE

Nov 23, 2020 in PHP by Niroj
• 82,840 points
2,997 views
0 votes
1 answer

How to enable PHP support in Netbeans?

Hello @kartik, Go to Tools->Plugins. In the Settings tab ensure that the ...READ MORE

Nov 5, 2020 in PHP by Niroj
• 82,840 points
3,774 views
0 votes
1 answer

How can I loop through all the properties of object using php?

Hello @kartik, If this is just for debugging ...READ MORE

Nov 10, 2020 in PHP by Niroj
• 82,840 points
3,525 views
0 votes
1 answer

How to set time zone in codeigniter?

Hii, Add this line inside the main index.php of codeigniter ...READ MORE

Nov 6, 2020 in PHP by Niroj
• 82,840 points
3,660 views
0 votes
1 answer

How to escape strings in SQL Server using PHP?

Hello @kartik, addslashes() isn't fully adequate, but PHP's mssql ...READ MORE

Oct 6, 2020 in PHP by Niroj
• 82,840 points
4,991 views
0 votes
1 answer

How to verify if $_GET exists?

You can use isset function: if(isset($_GET['id'])) { ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,840 points
3,958 views
0 votes
1 answer

Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity,

Hello @kartik, To evaporate the warning, you can ...READ MORE

Oct 6, 2020 in PHP by Niroj
• 82,840 points
4,982 views
0 votes
1 answer

How do I make a PHP form that submits to self?

Hello @kartik, The proper way would be to ...READ MORE

Nov 6, 2020 in PHP by Niroj
• 82,840 points
3,631 views
0 votes
1 answer

How to get the http headers from current request in PHP?

Hello, Try this code: if (!function_exists('getallheaders')) { ...READ MORE

Nov 23, 2020 in PHP by Niroj
• 82,840 points
2,800 views
0 votes
1 answer

PHP Error: Function name must be a string

Hello @kartik, It should be $_COOKIE['name'], not $_COOKIE('name') $_COOKIE is an array, ...READ MORE

Nov 4, 2020 in PHP by Niroj
• 82,840 points
3,618 views
0 votes
1 answer

How can I enable the MySQLi extension in PHP 7?

Hello @kartik, The problem is that the package ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,840 points
3,829 views
0 votes
1 answer

Error:Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23

Hello @kartik, This error message gets triggered when anything is ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,840 points
5,693 views
0 votes
1 answer

How to check an IP address is within a range of two IPs in PHP?

Hello @kartik, With ip2long() it's easy to convert your addresses ...READ MORE

Nov 3, 2020 in PHP by Niroj
• 82,840 points
3,619 views
0 votes
1 answer

How to get request string without GET arguments?

Hello @kartik, You can use $_SERVER['REQUEST_URI'] to get requested path. ...READ MORE

Nov 14, 2020 in PHP by Niroj
• 82,840 points
3,118 views
0 votes
1 answer

How to run process with realtime output in PHP?

Hello @kartik, This worked for me: $cmd = "ping ...READ MORE

Oct 20, 2020 in PHP by Niroj
• 82,840 points
4,172 views