How to create connection in php?



How to create connection in php?..

Answer / Ravi Dhawan

To create a connection in PHP, you can use the PDO (PHP Data Objects) extension or mysqli extension. Here's an example using PDO:

```php
$db = new PDO('mysql:host=localhost;dbname=database_name', 'username', 'password');
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

How many ways to include array elements in double-quoted strings using php?

1 Answers  


What does $_server mean?

1 Answers  


How do you compare strings in java?

1 Answers  


What are the advantages and disadvantages of cascade style sheets?

1 Answers  


What software is required to run php?

1 Answers  


How escape single quotes php?

1 Answers  


What is the use of nl2br() in php?

1 Answers  


What is the method to execute a php script from the command line?

1 Answers  


How session works (internal processing of session) ?

3 Answers   ASD Lab, IPSR Solutions,


Tell me how can you pass a variable by reference?

1 Answers  


Does php pass arrays by reference?

1 Answers  


What are the different methods of passing data or information between two calls of a web page? What are the advantages/disadvantages of these methods?

4 Answers   Ardo, Patni,


Categories