-
Download and extract source code into
C:\php -
copy
C:\php\php.ini-developmentinto a new file calledC:\php\php.ini -
edit
php.inito include any required extensions, such as:extension=curl extension=gd extension=mbstring extension=pdo_mysqlIf you want to send emails using PHP’s
mail()function, enter the details of an SMTP server in the[mail function]section (your ISP’s server should be suitable):[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = mail.myisp.com ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = [email protected]
-
Add
C:\phptoPATHenvironment variableWindows Start --> environment --> Edit system environment variables --> Advanced --> Environment Variables button --> scroll down System variables list --> click Path --> Edit button --> New --> add
C:\php
<html>
<head></head>
<body>
<?php
?>
</body>
</html>https://www.apachefriends.org/index.html
https://www.youtube.com/watch?v=X0_pthMQPMM
XAMPP (Win 10) - start control panel, then open browser to http://localhost/dashboard/ to access GUI for PHP, database, etc.
- To run
.phpfiles in your local browser, copy them into a subfolder inC:\php\htdocs\and then open them from there using the pathlocalhost/[subfolder]/file.phpin your web browser after XAMPP is running the apache server and any other needed resources phpinfo()- setdisplay_errorstoonduring development but make sure it's set tooffin production;
Change setting:
- press
configbutton next toapachein XAMPP Control Panel php.ini- ctrl + f 'display_errors'
- save file
- restart apache server
- go to admin page, phpinfo(), double-check setting is correct
- short-open tags are bad form (
<? ?>,<?= ?>) - ASP-style tags are very bad form (
<%= %>) - the above reduce portability and require changes to .ini file to work
- whitespace doesn't matter
<?php phpinfo(); ?>- php needs to be saved in files ending in
.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World</title>
</head>
<body>
<?php
// single-line comment
# or like this
/* multi-line
comments
*/
?>
<?php echo "Hello world<br />"; ?>
<?php
echo 2 + 3; // --> 5
$greeting = "Hello";
$target = "World";
$phrase = $greeting . " " . $target;
echo $phrase;
echo "$phrase again, another way to concatenate<br />";
?>
</body>
</html>- start with
$, followed by letter or underscore - can contain letters, numbers, underscores or dashes
- no spaces, case-sensitive
- concatenate strings with a dot
$phrase = $greeting . " " . $target; - concatenate variables with string literals using double quotes, optionally, make it very clear visually with braces, i.e.,
echo "{$phrase} again<br />";