Most answered questions in PHP

0 votes
1 answer

How to properly indent PHP/HTML mixed code?

Hello @kartik, The PHP and the HTML should ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,880 points
1,659 views
0 votes
1 answer

How to Check for a Specific Type of Object in PHP

Hello @kartik, You can use instanceof: if ($pdo instanceof PDO) ...READ MORE

Oct 30, 2020 in PHP by Niroj
• 82,880 points
1,414 views
0 votes
1 answer

How can I replace the deprecated set_magic_quotes_runtime in php?

Hello @kartik, I used FPDF v. 1.53 and ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
7,070 views
0 votes
1 answer

Fatal error: Call to undefined function imap_open() in PHP

Hello @kartik, In Ubuntu for install imap use sudo ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
5,082 views
0 votes
1 answer

How to check if the request is an AJAX request with PHP?

Hello @kartik, Try below code snippet if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
11,118 views
0 votes
1 answer

How to properly indent PHP/HTML mixed code?

The PHP and the HTML should each ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
452 views
0 votes
1 answer

How to enable curl in xampp?

Hello @kartik, You have to modify the php.ini ...READ MORE

Oct 29, 2020 in PHP by Niroj
• 82,880 points
2,423 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,880 points
3,805 views
0 votes
1 answer

How to include External CSS and JS file in Laravel?

Hello @kartik, The right way is this one: <script ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
27,755 views
0 votes
1 answer

How To Run PHP From Windows Command Line in WAMPServer

Hello @kartik, Try using batch file Open notepad type php -S ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
2,478 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,880 points
4,054 views
0 votes
1 answer

How to create and download a csv file from php script?

Hello @kartik, You can use the built in fputcsv() for ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
6,585 views
0 votes
1 answer

How to add a line break within echo in PHP?

Hello @kartik, You have to use br when ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
2,351 views
0 votes
1 answer

How to remove GET-variables with PHP?

Hello @kartik, Try this: preg_replace('/\\?.*/', '', $str) Hope ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
1,813 views
0 votes
1 answer

error: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in...

Hello @kartik, Use this SQL command: ALTER USER 'mysqlUsername'@'localhost' ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
23,578 views
0 votes
1 answer

How to delete all cookies of my website in php?

Hello @kartik, This will unset all of the ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
7,780 views
0 votes
1 answer

How can I get the classname from a static call in an extended PHP class?

Hello @kartik, __CLASS__ always returns the name of the ...READ MORE

Oct 27, 2020 in PHP by Niroj
• 82,880 points
769 views
0 votes
1 answer

How to set upload_max_filesize in .htaccess?

Hello @kartik, php_value upload_max_filesize 30M is correct. You will have ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
1,028 views
0 votes
1 answer

How do I get the last inserted ID of a MySQL table in PHP?

Hello @kartik, If you're using PDO, use PDO::lastInsertId. If you're ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
1,918 views
0 votes
1 answer

Catchable fatal error: Argument 1 passed to ClassA::method_a() must be an instance of ClassB, instance of ClassWrong given..

Hello @kartik, This is not a catchable fatal ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
579 views
0 votes
1 answer

In PHP, how to detect the execution is from CLI mode or through browser ?

Hello @kartik, Use the php_sapi_name() function. if (php_sapi_name() == "cli") { ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
1,060 views
0 votes
1 answer

How to send email with PHPMailer - embed image in body?

Hello @kartik, I found the answer: $mail->AddEmbeddedImage('img/2u_cs_mini.jpg', 'logo_2u'); and on ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
10,475 views
0 votes
1 answer

How can I get enum possible values in a MySQL database?

Hello @kartik, I have a codeigniter version for ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
2,366 views
0 votes
1 answer

How do I make an asynchronous GET request in PHP?

Hello @kartik, Works with both POST and GET ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
1,433 views
0 votes
1 answer

How to get innerHTML of DOMNode?

Hello @kartik, Here is a version in a functional ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
907 views
0 votes
1 answer

How do I add PHP code/file to HTML(.html) files?

Hello @kartik, You can't run PHP in .html ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
513 views
0 votes
1 answer

How can I use break or continue within for loop in Twig template?

Hello @kartik, This can be nearly done by setting a ...READ MORE

Oct 22, 2020 in PHP by Niroj
• 82,880 points
9,172 views
0 votes
1 answer

How to create virtual column using MySQL SELECT?

Hello, Something like: SELECT id, email, IF(active = 1, ...READ MORE

Oct 20, 2020 in PHP by Niroj
• 82,880 points
2,978 views
0 votes
1 answer

How to view query error in PDO PHP?

Hello, You need to set the error mode ...READ MORE

Oct 20, 2020 in PHP by Niroj
• 82,880 points
5,562 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,880 points
4,992 views
0 votes
1 answer

How to configuring a xampp web server for different root directory?

Hello @kartik, You can change Apaches httpd.conf by ...READ MORE

Oct 20, 2020 in PHP by Niroj
• 82,880 points
10,928 views
0 votes
1 answer

How to list all tables in PhpMyAdmin's left menu?

Hello @kartik, Go to the phpMyAdmin Home page ...READ MORE

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

How to make form_rest() not display a field with Symfony2?

Hello @kartik, Another option is to explicitly mark ...READ MORE

Oct 20, 2020 in PHP by Niroj
• 82,880 points
955 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,880 points
4,618 views
0 votes
1 answer

Error:PHP Notice: Undefined offset: 1

Hello @kartik, Change $data[$parts[0]] = $parts[1]; to if ( ! isset($parts[1])) ...READ MORE

Oct 20, 2020 in PHP by Niroj
• 82,880 points
7,117 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,880 points
3,512 views
0 votes
1 answer

How to run composer from anywhere?

Since Composer works with the current working ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
11,501 views
0 votes
1 answer

How to prevent my site page to be loaded via 3rd party site frame of iFrame?

Hello @kartik, You cannot check it from the ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
937 views
0 votes
1 answer

Fatal error: Cannot access empty property in C:\xampp\htdocs\MyTestPages\f.php on line 15

Hello @kartik, You access the property in the ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
1,512 views
0 votes
1 answer

How do I make a PATCH request in PHP using cURL?

Hello @kartik, Use this: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH'); should do it. Hope ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
7,431 views
0 votes
1 answer

How to print all session variables currently set?

Hello @kartik, Use this: echo '<pre>'; var_dump($_SESSION); echo '</pre>'; Or you can ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
8,764 views
0 votes
1 answer

How to get response using cURL in PHP?

Hello @kartik, Use the below piece of code ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
6,153 views
0 votes
1 answer

How to properly URL encode a string in PHP?

Hello @kartik, For the URI query use urlencode/urldecode; for ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
2,870 views
0 votes
1 answer

How do I PHP-unserialize a jQuery-serialized form?

Hello @kartik, Provided that your server is receiving ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
3,565 views
0 votes
1 answer

How to creat and Update Laravel Eloquent?

Hello @kartik, Here's a full example of what ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
570 views
0 votes
1 answer

How to prevent direct access to a php include file?

Hello @kartik, Add this to the page that ...READ MORE

Oct 19, 2020 in PHP by Niroj
• 82,880 points
1,485 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,880 points
4,361 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,880 points
4,353 views
0 votes
1 answer

How do I get the HTML code of a web page in PHP?

Hello @kartik, If your PHP server allows url ...READ MORE

Oct 6, 2020 in PHP by Niroj
• 82,880 points
7,659 views