PHP Mastering PHP and MySQL: A Beginner's Guide

  • Thread starter Thread starter webdevelopment
  • Start date Start date
  • Tags Tags
    Php
Click For Summary
To learn PHP and MySQL, start by setting up a local environment using tools like XAMPP, which allows you to run PHP scripts and manage MySQL databases efficiently. Familiarize yourself with PHP syntax and programming logic through practice, similar to learning basic math. While XAMPP is suitable for Windows, alternatives like IIS plugins exist for those who prefer Windows environments. Beginners are encouraged to explore PHP frameworks such as Yii, Laravel, and CodeIgniter after grasping the basics, as these frameworks follow the MVC design pattern and can enhance development skills. It's also recommended to understand basic web server configurations, as this knowledge aids in the effective use of PHP in various environments. However, some argue that beginners can focus on PHP scripting without delving deeply into web server complexities initially. Ultimately, a solid foundation in PHP, MySQL, and basic server knowledge will pave the way for a successful programming career.
webdevelopment
Messages
3
Reaction score
0
I want to learn about and PHP and MysQuL. Someone tell me How to learn it?
 
Technology news on Phys.org
First you need to have a means to run php scripts as well as run MySQL, either from an existing web hosting service or on your own computer. Then you start learning the syntax, programming logic, etc.

As for "how to learn", you'd learn the same way you learned how to do multiplication: read up on the process and start practicing to apply the knowledge.
 
elusiveshame said:
First you need to have a means to run php scripts as well as run MySQL, either from an existing web hosting service or on your own computer. Then you start learning the syntax, programming logic, etc.
Use your computer because it's faster than web servers andI use xampp for that.
 
adjacent said:
Use your computer because it's faster than web servers andI use xampp for that.

Agreed. There are also IIS plugins for windows if the op doesn't want to use Linux, as well as other 3rd party web servers that are free, though I've only ever tested xitami a few years ago (probably 10 years at this point) when I there were some major security risks with IIS 6.
 
elusiveshame said:
Agreed. There are also IIS plugins for windows

Xampp works perfectly well under Windows.
 
Borek said:
Xampp works perfectly well under Windows.


Ah, I'm not familiar with xampp, to be perfectly honest. I thought it was a Linux specific software. Looks like another thing I need to learn about :) thanks for that!
 
You want a library called Pdo, it should be built into your php install.
 
  • #10
elusiveshame said:
Ah, I'm not familiar with xampp, to be perfectly honest. I thought it was a Linux specific software. Looks like another thing I need to learn about :) thanks for that!
All you need to learn PHP as a beginner is the PHP library itself plus a web server to serve your client requests implemented and provoked via use of PHP language, its included application files and tools after a successful installation of it is done. Many servers nowadays run on Unix systems (without GUI), so you need to learn Linux or Unix terminal well (common tasks such as installing and updating/upgrading components, spawning processes and running them in the background, compiling files, searching and displaying, backtracking memory used by processes, networking etc are a few of priorities coming to my mind now). If you choose to do things with PHP in a fairly big company, you are meant to work with the so called the back-end technology, and so the front-end technology (GUI designs, javascript, css html etc) is left for others.
PHP frameworks to work with are plenty. But I would suggest you first to make yourself acquainted with n-tier or n-layer software architecture, particularly MVC design pattern, the try to be skilled in presently commonly used frameworks such as Laravel, CodeIgniter, CakePHP, etc and last but not least one or two CMS systems to pave your way to the good career life of a PHP programmer.
 
  • #12
Silicon Waffle said:
All you need to learn PHP as a beginner is the PHP library itself plus a web server to serve your client requests implemented and provoked via use of PHP language
I highly recommend against doing it that way to learn. That adds an extra level of complexity, you'll have to install and configure apache,it's modules, and add a link to the php in the conf.d file. I recommend just running from the command line, if he's trying to learn how to interface with mysql, adding a web server to the mix makes things harder.

test.php
Code:
<?php
echo "Hello world, I am PHP!" . PHP_EOL;

$dbname = 'mytestschema';
$host = 'localhost';

$connection = new \PDO(
    "mysql:dbname=$dbname;host=$hostip",
    'username',
    'password'
);

if ($connection){
    echo 'Got the MySQL connection!' . PHP_EOL;
} else {
   die('Couldn\'t create the MySQL connection');
}

In your command line:
Code:
php test.php
 
  • #13
newjerseyrunner said:
[...] adding a web server to the mix makes things harder.
[...]
Being without knowing how to configure his web server I think will be the biggest mistake he makes in learning PHP in the first place. Web servers run with predefined configured files. I can't imagine one claiming he would want to learn things in close relation to those web servers but ignore their configuration file contents. Basically, he will not learn where his root directory is, :biggrin: for instance, and be unable to change it into wherever he wants. I have yet to mention he would also have no knowledge of how to create virtual directories in general, to add new modules to interact with PHP in different working platforms or environments, to remove use of MySQL and replace it with MSSQL Server or Oracle, for example, etc. Advanced knowledge of web servers is not necessary for PHP beginners but a minimal amount of it that helps coders to understand its main functions during its interactions with PHP is truly required.
 
  • #14
I see no indication from the post that the OP had any interest in web servers. PHP is used for more than just handling web traffic. Root directories, virtual directories... are all web specific. I use php for writing scripts very quickly, I almost never attach them to apache or nginx.

Removing MySQL and replacing it with oracle for example has nothing to do with the web server, it has to do with good program design. He should not have to alter his code whatsoever to switch from MySQL to something else if he has written the data access layer correctly. He should merely have to write a new module.
 
  • #15
PHP:
<?php
date_default_timezone_set("UTC");

$dates = array("May 19, 2014", "Jun 18, 2014");

foreach ($dates as $date) {
    $days_elapsed = intval((strtotime("today") - strtotime($date)) / 86400);
    $days = ($days_elapsed != 1) ? "days" : "day";
    $years = floor($days_elapsed / 365.2425);

    if ($years == 0)
        $stop = ".";
    elseif ($years > 0)
        $stop = str_repeat("!", $years);
    else
        $stop = "...?!";
    
    echo "$date was $days_elapsed $days ago${stop}\n";
}
?>

Code:
$ php date.php
May 19, 2014 was 463 days ago!
Jun 18, 2014 was 433 days ago!

Seems straightforward enough.
 
  • #16
@wle There are also classes for that now :P
 

Similar threads

  • · Replies 21 ·
Replies
21
Views
6K
  • · Replies 187 ·
7
Replies
187
Views
11K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 23 ·
Replies
23
Views
4K