Most viewed questions in PHP

0 votes
1 answer

How to check if php session is already started or not?

Hello kartik, Use session_id(), it returns an empty string ...READ MORE

Apr 1, 2020 in PHP by Niroj
• 82,880 points
5,141 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,139 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,880 points
5,086 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
5,041 views
0 votes
1 answer

How do I get a YouTube video thumbnail from the YouTube API?

Hello @kartik, Each YouTube video has four generated ...READ MORE

Jun 16, 2020 in PHP by Niroj
• 82,880 points
5,029 views
0 votes
1 answer

How can I connect to a Tor hidden service using CURL in PHP?

Hello @kartik, I use Privoxy and cURL to scrape Tor ...READ MORE

May 19, 2020 in PHP by Niroj
• 82,880 points
4,946 views
0 votes
0 answers

How to pass a PHP variable using the URL

I need to pass some PHP variables ...READ MORE

Jun 19, 2022 in PHP by narikkadan
• 63,420 points
4,882 views
0 votes
1 answer

PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR

Hello @kartik, Change your syntax because it  was invalid. Updated syntax: $purchaseOrder = ...READ MORE

May 19, 2020 in PHP by Niroj
• 82,880 points
4,840 views
0 votes
1 answer

How to skip tests in PHPunit?

Hello, The fastest and easiest way to skip ...READ MORE

Nov 10, 2020 in PHP by Niroj
• 82,880 points
4,735 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,880 points
4,709 views
0 votes
1 answer

Error:Got a packet bigger than 'max_allowed_packet'bytes

Hello @kartik, max_allowed_packet is set in mysql config, not ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
4,687 views
0 votes
1 answer

Php exec() not returning error message in output

Hello @kartik, You need to capture the stderr too. Redirecting stderr to stdout should do ...READ MORE

Nov 18, 2020 in PHP by Niroj
• 82,880 points
4,681 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,681 views
0 votes
1 answer

ERROR: The file 'wp-config.php' already exists

Hello, Try to display the website first on ...READ MORE

May 8, 2020 in PHP by Niroj
• 82,880 points
4,585 views
0 votes
1 answer

How to resolve “must be an instance of string, string given” prior to PHP 7?

Hello, Prior to PHP 7 type hinting can only be ...READ MORE

Apr 20, 2020 in PHP by I Navin
• 220 points
4,579 views
0 votes
0 answers

I can't access http://localhost/phpmyadmin/

I am not able to access:  localhost/phpmyadmin/ ...READ MORE

May 28, 2022 in PHP by Kichu
• 19,050 points
4,570 views
0 votes
0 answers

PHP json encode - Malformed UTF-8 characters, possibly incorrectly encoded

I am using json_encode($data) on an array ...READ MORE

Jun 27, 2022 in PHP by narikkadan
• 63,420 points
4,533 views
0 votes
1 answer

How to get file_get_contents() to work with HTTPS?

Hello @kartik, Try the following script to see ...READ MORE

Sep 1, 2020 in PHP by Niroj
• 82,880 points
4,483 views
0 votes
1 answer

Error:Trying to get property of non-object in C:\wamp\www\ni\pages\init.php..

Hello, Try mysql_fetch_object(). It returns an object, not an ...READ MORE

Nov 19, 2020 in PHP by Niroj
• 82,880 points
4,468 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,428 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,408 views
0 votes
1 answer

How to write CDATA using SimpleXmlElement?

Hello @kartik, Try this: class MySimpleXMLElement extends SimpleXMLElement{ ...READ MORE

Nov 17, 2020 in PHP by Niroj
• 82,880 points
4,394 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,880 points
4,382 views
0 votes
0 answers

selected value get from db into dropdown select box option using php mysql error

I have to get the selected value ...READ MORE

Jul 31, 2022 in PHP by Kithuzzz
• 38,010 points
4,338 views
0 votes
1 answer

How do I specify unique constraint for multiple columns in MySQL?

Hello @kartik, Use this: ALTER TABLE `votes` ADD UNIQUE ...READ MORE

Aug 18, 2020 in PHP by Niroj
• 82,880 points
4,320 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,880 points
4,308 views
0 votes
1 answer

How do I convert a PDF document to a preview image in PHP?

Hello @kartik, You need ImageMagick and GhostScript <?php $im = new imagick('file.pdf[0]'); $im->setImageFormat('jpg'); header('Content-Type: image/jpeg'); echo ...READ MORE

Aug 14, 2020 in PHP by Niroj
• 82,880 points
4,300 views
0 votes
1 answer

How to grant remote access permissions to mysql server for user?

Hello @kartik, This grants root access with the ...READ MORE

Aug 26, 2020 in PHP by Niroj
• 82,880 points
4,245 views
0 votes
0 answers

"SMTP Error: Could not authenticate" in PHPMailer

I want to send emails in Gmail ...READ MORE

May 7, 2022 in PHP by narikkadan
• 63,420 points
4,216 views
0 votes
1 answer

Error:No Application Encryption Key Has Been Specified

Hello @kartik, Open command prompt in the root ...READ MORE

Jul 22, 2020 in PHP by Niroj
• 82,880 points
4,207 views
0 votes
1 answer

How to Insert multiple rows in a single SQL query?

Hello @kartik, In SQL Server you can insert ...READ MORE

Jul 21, 2020 in PHP by Niroj
• 82,880 points
4,189 views
0 votes
1 answer

How to get name of current directory using php?

Hello @kartik, To get only the name of ...READ MORE

Aug 27, 2020 in PHP by Niroj
• 82,880 points
4,188 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,152 views
0 votes
1 answer

How can I disable XDebug using php?

Hello @kartik, Find your php.ini and look for XDebug. Set xdebug ...READ MORE

Aug 27, 2020 in PHP by Niroj
• 82,880 points
4,150 views
0 votes
1 answer

error: Class 'PHPUnit_Framework_TestCase' not found in …?

Hello,  You can use TestCase instead PHPUnit_Framework_TestCase // use the following namespace use ...READ MORE

Apr 20, 2020 in PHP by Niroj
• 82,880 points
4,141 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,880 points
4,118 views
0 votes
0 answers

I can't enter to "localhost:8080/phpmyadmin"

When I tried to enter it returns ...READ MORE

Jun 11, 2022 in PHP by narikkadan
• 63,420 points
4,075 views
0 votes
1 answer

How to enable cURL in PHP / XAMPP?

Hello @kartik, Since you're using XAMPP, uncomment the ...READ MORE

Oct 1, 2020 in PHP by Niroj
• 82,880 points
4,042 views
0 votes
0 answers

localhost/xampp/ or http://localhost/index.php can't be accessed

I am trying to install xampp. But ...READ MORE

May 28, 2022 in PHP by Kichu
• 19,050 points
4,011 views
0 votes
1 answer

How to change the session timeout in PHP?

Hello @kartik, Put $_SESSION['login_time'] = time(); into the previous authentication ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
4,001 views
0 votes
1 answer

How to set up file permissions for Laravel?

Hello @kartik, The permissions for the storage and vendor folders should stay ...READ MORE

Apr 20, 2020 in PHP by I Navin
• 220 points
3,968 views
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,880 points
3,929 views
0 votes
1 answer

Invalid argument supplied for foreach() on line 25. Error in my php and mysql

Hello @viven , This should be a simple fix ...READ MORE

Aug 4, 2020 in PHP by Niroj
• 82,880 points
3,888 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,887 views
0 votes
1 answer

How to get Redux Form data in another Component?

Hello @kartik, What you need to do is ...READ MORE

Jun 1, 2020 in PHP by Niroj
• 82,880 points
3,887 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,880 points
3,803 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,880 points
3,792 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,880 points
3,787 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,880 points
3,782 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,880 points
3,759 views