Most answered questions in PHP

0 votes
1 answer

How to use PHP's password_hash to hash and verify passwords?

Hello @kartik, Using password_hash is the recommended way to store ...READ MORE

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

How to comment out HTML and PHP together?

Hello @kartik, Instead of using HTML comments (which have ...READ MORE

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

How to truncate string in Laravel blade templates?

Hello @kartik, In Laravel 4 & 5 (up ...READ MORE

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

How to submit form without page reloading?

Hello @kartik, If you put an Iframe in ...READ MORE

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

How to search for highest key/index in an array?

Hello @kartik, This should work fine $arr = array( ...READ MORE

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

How to get Real IP from Visitor?

Hello @kartik, Try this php code. <?PHP function getUserIP() { ...READ MORE

Oct 6, 2020 in PHP by Niroj
• 82,880 points
1,692 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
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,880 points
5,594 views
0 votes
1 answer

How to execute PHP code from the command line?

Hello @kartik, the php command offers two switches to ...READ MORE

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

How do I disable the views caching?

Hello @kartik, There is now a php artisan view:clear command ...READ MORE

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

Error:Failed to open stream : No such file or directory.

Hello @kartik, Go to the file to include ...READ MORE

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

How can I declare a global variable in php?

Hello @kartik, The $GLOBALS array can be used instead: $GLOBALS['a'] = ...READ MORE

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

I want to store some photos for a product using sql?

Hello, if you are going to store the ...READ MORE

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

How to delete a file via PHP?

Hello @kartik, The following should help realpath — Returns canonicalized ...READ MORE

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

How to get base url in laravel using php?

Hello @kartik, You can use the URL facade ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
16,486 views
0 votes
1 answer

How do you create optional arguments in php?

Hello @kartik, Use an equals (=) sign in ...READ MORE

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

How to GET URL parameter in PHP?

Hello @kartik, $_GET is not a function or language ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
3,497 views
0 votes
1 answer

How to trigger XDebug profiler for a command line PHP script?

Hello @kartik, You can pass INI settings with ...READ MORE

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

How to get the location from an IP address?

Hello @kartik, You could download a free GeoIP ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
2,107 views
0 votes
1 answer

How to display HTML tags as plain text ?

Hello @kartik, Replace < with &lt; and& ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
2,495 views
0 votes
1 answer

How to remove all special characters from a string?

Hello @kartik, This should do what you're looking ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
10,676 views
0 votes
1 answer

Error:PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

Hello @kartik, 8388608 bytes is 8M, the default ...READ MORE

Sep 17, 2020 in PHP by Niroj
• 82,880 points
27,566 views
0 votes
1 answer

How to secure database passwords in PHP

Hello @kartik, If you're hosting on someone else's ...READ MORE

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

How can I get useful error messages in PHP?

Hello @kartik, The following enables all errors: ini_set('display_startup_errors', 1); ini_set('display_errors', ...READ MORE

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

How can I capture the result of var_dump to a string?

Hello @kartik, Try var_export You may want to check out var_export — ...READ MORE

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

How do I send a POST request with PHP?

Hello @kartik, CURL-less method with PHP5: $url = 'http://server.com/path'; $data ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
2,713 views
0 votes
1 answer

How do I get a file extension in PHP?

Hello @kartik, pathinfo() $path_info = pathinfo('/foo/bar/baz.bill'); echo $path_info['extension']; // "bill" Hope ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
780 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,880 points
5,397 views
0 votes
1 answer

How to delete element by value in array (not key) using php?

Hello @kartik, Using array_search() and unset, try the following: if (($key = ...READ MORE

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

Error:mysql_fetch_array() expects parameter 1 to be resource, boolean given

Hello @kartik, Error occurred here was due to ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
3,497 views
0 votes
1 answer

How to Get the full URL in PHP?

Hello @kartik, Have a look at $_SERVER['REQUEST_URI'], i.e. $actual_link = ...READ MORE

Sep 16, 2020 in PHP by Niroj
• 82,880 points
2,900 views
0 votes
1 answer

How do I make a redirect in PHP?

Hello @kartik, Use the header() function to send an HTTP Location header: header('Location: '.$newURL); Contrary to ...READ MORE

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

How to generate .json file with PHP?

Hello @kartik, Here is a sample code: <?php $sql="select ...READ MORE

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

How can I convert the output of PHP's filesize() function to a format with MegaBytes, KiloBytes etc?

Hello @kartik, Here is a sample: <?php // Snippet from ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
3,393 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,880 points
6,595 views
0 votes
1 answer

How do I get the base URL with PHP?

Hello @kartik, Try this: <?php echo "http://" . $_SERVER['SERVER_NAME'] ...READ MORE

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

How to remove duplicate values from an array in PHP?

Hello @kartik, Use array_unique(): Example: $array = array(1, 2, 2, 3); $array ...READ MORE

Sep 15, 2020 in PHP by Niroj
• 82,880 points
2,526 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 can I select and upload multiple files with HTML and PHP using HTTP POST?

Hello @kartik, This is possible in HTML5. Example (PHP ...READ MORE

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

How do I see the extensions loaded by PHP?

Hello @kartik, Running php -m will give you all the ...READ MORE

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

How to copy a file from one directory to another using PHP?

Hello @kartik, You could use the copy() function : // Will ...READ MORE

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

How to Get $_POST from multiple checkboxes?

Hello @kartik, Set the name in the form ...READ MORE

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

How to Convert timestamp to readable date/time PHP?

Hello @kartik, Use PHP's date() function. Example: echo date('m/d/Y', 1299446702); Hope it helps!! Thank ...READ MORE

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

How to send HTTP response code?

Hello @kartik, you can use http_response_code() for get and set ...READ MORE

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

How to receive JSON POST with PHP?

Hello @kartik, Try; $data = json_decode(file_get_contents('php://input'), true); print_r($data); echo $data["operacion"]; From your ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
13,789 views
0 votes
1 answer

How do you Encrypt and Decrypt a PHP String?

Hello @kartik, Use openssl_encrypt and openssl_decrypt You can do something like: $string_to_encrypt="Test"; $password="password"; $encrypted_string=openssl_encrypt($string_to_encrypt,"AES-128-ECB",$password); $decrypted_string=openssl_decrypt($encrypted_string,"AES-128-ECB",$password); Hope it ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
7,996 views
0 votes
1 answer

How do I log errors and warnings into a file?

Hello @kartik, Use the following code: ini_set("log_errors", 1); ini_set("error_log", "/tmp/php-error.log"); error_log( ...READ MORE

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

How to configure XAMPP to send mail from localhost?

Hello @kartik, You can send mail from localhost ...READ MORE

Sep 14, 2020 in PHP by Niroj
• 82,880 points
11,478 views