Most voted questions in PHP

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,880 points
3,075 views
0 votes
1 answer

How to pass multiple variables to another page in url?

Hello @kartik, Use the ampersand & to glue variables together: $url ...READ MORE

Nov 23, 2020 in PHP by Niroj
• 82,880 points
21,017 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,880 points
2,431 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,880 points
2,625 views
0 votes
1 answer

How to drop softDeletes from a table in a migration?

Hello, On your migration class: public function down() { ...READ MORE

Nov 23, 2020 in PHP by Niroj
• 82,880 points
1,323 views
0 votes
1 answer

Error:preg_match() [function.preg-match]: Unknown modifier '+' in raptr.php on line 14

Hello, Try this code: preg_match('/[a-zA-Z]+<\/a>.$/', $lastgame, $match); print_r($match); Using / as a delimiter ...READ MORE

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

How to use a string path to set nested array data?

Hello @kartik, Use the reference operator to get ...READ MORE

Nov 23, 2020 in PHP by Niroj
• 82,880 points
1,833 views
0 votes
1 answer

How to fix the session_register() deprecated issue?

Hello, Use $_SESSION directly to set variables. Like this: $_SESSION['name'] = 'stack'; Instead ...READ MORE

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

How can I ping a server port with PHP?

Hello, Try this : echo exec('ping -n 1 -w ...READ MORE

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

How do I make global helper functions in laravel?

Hello @kartik, Create a new file in your ...READ MORE

Nov 22, 2020 in PHP by Niroj
• 82,880 points
1,196 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,880 points
2,707 views
0 votes
1 answer

How to render CSRF input in twig?

Hello @kartik, You can do it with {{ form_widget(formView._token) ...READ MORE

Nov 22, 2020 in PHP by Niroj
• 82,880 points
883 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,880 points
2,773 views
0 votes
1 answer

How to get input field value using PHP?

Hello, Use PHP's $_POST or $_GET superglobals to retrieve the value of ...READ MORE

Nov 20, 2020 in PHP by Niroj
• 82,880 points
67,735 views
0 votes
1 answer

How to extract URLs from text in PHP?

Hello, A simple example capturing anything starting with http:// and https:// could ...READ MORE

Nov 20, 2020 in PHP by Niroj
• 82,880 points
6,015 views
0 votes
1 answer

How do I access static member of a class?

Hello, If A is a class, you can access it ...READ MORE

Nov 20, 2020 in PHP by Niroj
• 82,880 points
349 views
0 votes
1 answer

Error:fetching http headers in SoapClient

Hello, This error is often seen when the default_socket_timeout value ...READ MORE

Nov 20, 2020 in PHP by Niroj
• 82,880 points
7,174 views
0 votes
1 answer

How to remove new lines and returns from php string?

Hello @kartik, You need to place the \n in double ...READ MORE

Nov 19, 2020 in PHP by Niroj
• 82,880 points
13,359 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,472 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,880 points
3,245 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,880 points
3,503 views
0 votes
1 answer

How do I remove http, https and slash from user input in php

Hello @kartik, Use: $url = preg_replace("(^https?://)", "", $url ); This ...READ MORE

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

Fatal error: Call to undefined function ImageCreate() in /home/t1g01/phplot.php on line 248

Hello @kartik, Your server most like does not ...READ MORE

Nov 18, 2020 in PHP by Niroj
• 82,880 points
5,865 views
0 votes
1 answer

How to read a list of files from a folder using PHP?

Try this: $files = array_values(array_filter(scandir($path), function($file) use ($path) ...READ MORE

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

How can I get the session ID in Laravel?

Hii, Use: $session_id = Session::getId(); or $session_id = ses ...READ MORE

Nov 18, 2020 in PHP by Niroj
• 82,880 points
5,484 views
0 votes
1 answer

How to Execute php file from another php?

Hello @kartik, It's trying to run it as ...READ MORE

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

How can to make a query with LIKE and get all results with mysqli ?

Hello @kartik, Here's how you properly fetch the ...READ MORE

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

How do I save value in my own session variable in Magento?

Hello @kartik, Try this: $session = Mage::getSingleton("core/session", array("name"=>"frontend")); // ...READ MORE

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

mysql error 'TYPE=MyISAM'

Hello @kartik, Replace TYPE=MyISAM with ENGINE=MyISAM The problem was "TYPE=MyISAM" which should ...READ MORE

Nov 17, 2020 in PHP by Niroj
• 82,880 points
1,045 views
0 votes
0 answers

How do I connect to PostgreSQL without specifying a database name?

I need to connect to some PostgreSQL ...READ MORE

Nov 16, 2020 in PHP by kartik
• 37,510 points
1,288 views
0 votes
1 answer

How do I remove quotes from a string?

Hello @kartik, Try this: str_replace('"', "", $string); str_replace("'", "", $string); Otherwise, ...READ MORE

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

Error: Class 'NumberFormatter' not found

Hello @kartik, You just need to enable this ...READ MORE

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

How do I embed PHP code in JavaScript?

Hello @kartik, If your whole JavaScript code gets ...READ MORE

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

How to embed a .png image into an html page?

Hello @kartik, Try this: div.image { width:100px; ...READ MORE

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

How to find Object ID in PHP?

Hello @kartik, Use spl_object_hash() for that. It returns an unique identifier ...READ MORE

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

Error: Call to undefined function money_format()

Hello @kartik, If you are using windows based ...READ MORE

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

How do I find the mime-type of a file with php?

Hello @kartik, mime_content_type() is deprecated, so you won't ...READ MORE

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

How do I save value in my own session variable in Magento?

Hello @kartik, Let's say you want to save ...READ MORE

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

Error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 9

Hello @kartik, Replace TYPE=MyISAM with ENGINE=MyISAM The problem was "TYPE=MyISAM" which should ...READ MORE

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

How can I get PHP to produce a backtrace upon errors?

Hello @kartik, This is how you do it: set_error_handler(function($errorType){ ...READ MORE

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

How to return an array from an AJAX call?

Hello @kartik, Use JSON to transfer data types (arrays and ...READ MORE

Nov 14, 2020 in PHP by Niroj
• 82,880 points
16,481 views
0 votes
1 answer

How to save image from url with curl PHP?

Hello @kartik, try this: function grab_image($url,$saveto){ ...READ MORE

Nov 14, 2020 in PHP by Niroj
• 82,880 points
6,696 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,880 points
2,446 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,880 points
3,031 views
0 votes
1 answer

Error: Premature end of script headers: backup.php

Hello @kartik< Try this settings on my apache.conf: <VirtualHost ...READ MORE

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

How to set max_execution_time in PHP CLI?

Hello, set_time_limit() works in CLI scripts. <?php set_time_limit(1); //in ...READ MORE

Nov 14, 2020 in PHP by Niroj
• 82,880 points
869 views