Phpstudy For Mac

Phpstudy For Mac Average ratng: 7,4/10 7933 votes
For

No wonder it's worth learning PHP in Mac OS X. By Lucy Hattersley 06 Jul 16.

PHP‎ > ‎

PHP Study Notes

Contents

Download auto tune 7 full crack. Antares Auto-Tune 7.6.8 Free Download Latest Version for MAC OS. It is full offline installer standalone setup of Antares Auto-Tune 7.6.8 crack mac for macOS. Antares Auto-Tune 7.6.8 Overview Hailed at its introduction as a “holy grail of recording,” by Recording magazine (and adopted worldwide as the largest-selling audio plug-in of.

  1. 1 Introduction
  2. 2 Basic

Introduction

PHP : HyperText Preprocessor
PHP is server side scripting language, also open source which supports cross-platform development. It can be freely downloaded from http://www.php.net
PHP can be run on Apache / IIS server.

What is a PHP File?

  • PHP files can contain text, HTML, CSS, JavaScript, and PHP code
  • PHP code are executed on the server, and the result is returned to the browser as plain HTML
  • PHP files have extension '.php'

What Can PHP Do?

  • PHP can generate dynamic page content
  • PHP can create, open, read, write, delete, and close files on the server
  • PHP can collect form data
  • PHP can send and receive cookies
  • PHP can add, delete, modify data in your database
  • PHP can be used to control user-access
  • PHP can encrypt data

With PHP you are not limited to output HTML. You can output images, PDF files, and even Flash movies. You can also output any text, such as XHTML and XML.


Why PHP?

  • PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • PHP is compatible with almost all servers used today (Apache, IIS, etc.)
  • PHP supports a wide range of databases

Set Up PHP on Your Own PC

However, if your server does not support PHP, you must:

  • install a web server
  • install PHP
  • install a database, such as MySQL

The official PHP website (PHP.net) has installation instructions for PHP:http://php.net/manual/en/install.php


Apache Server

Install Apache on windows from here https://httpd.apache.org/docs/current/platform/windows.html. It will download a zip file, extract it and then run httpd.exe to run apache from command prompt.
If localhost is already used by IIS then Apache may find difficulty in starting. In that case change Apache address in confhttpd.conf file. Change it to :
Sometimes Skype interferes with this address, so if you still have problem starting Apache, try closing Skype.
You need to tell Apache to execute php scripts, to do that add following line in the httpd.conf file.

Also add following to add .php extentions

Test

To test create following file in the public folder of Apache
Apache24htdocsindex.php
<!DOCTYPE html>
<html>
<body>
<?php
echo 'My first PHP script!';
?>
</body>
</html>

Open browser and type following address
http://127.0.0.1:122/

If everything is fine then you should see following:

Basic

A PHP script starts with <?php and ends with ?>:


Comments

<?php
// This is a single-line comment

# This is also a single-line comment

/*
This is a multiple-lines comment block
that spans over multiple
lines
*/

Should start with $ sign, followed by name of variable. PHP has no command for declaring a variable. It is created the moment you first assign a value to it. PHP variable names are case-sensitive.
Variable Scope

A variable declared outside a function has a GLOBAL SCOPE and can only be accessed outside a function.
A variable declared within a function has a LOCAL SCOPE and can only be accessed within that function.
The global keyword is used to access a global variable from within a function.
To do this, use the global keyword before the variables (inside the function):
<?php
$x = 5;
$y = 10;
function myTest(){
global $x, $y;
$y = $x + $y;
}
myTest();
echo $y; // outputs 15
?>

PHP also stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable. This array is also accessible from within functions and can be used to update global variables directly.
<?php
$x = 5;
$y = 10;
function myTest(){
$GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];
}
myTest();
echo $y; // outputs 15
?>


Each time the function is called, that variable will still have the information it contained from the last time the function was called.
<?php
function myTest(){
static $x = 0;
echo $x;
$x++;
}
myTest();
myTest();
myTest();
?>

In PHP there are two basic ways to get output: echo and print.
Echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. echo is marginally faster than print.
The echo statement can be used with or without parentheses: echo or echo().

<?php
echo'<h2>PHP is Fun!</h2>';
echo'Hello world!<br>';
echo'I'm about to learn PHP!<br>';
echo'This ', 'string ', 'was ', 'made ', 'with multiple parameters.';
?>

Display Variables
<?php
$txt1 = 'Learn PHP';
$txt2 = 'W3Schools.com';
$x = 5;
$y = 4;
echo'<h2>$txt1</h2>';
echo'Study PHP at $txt2<br>';
echo $x + $y;
?>

PHP supports the following data types:

  • String
  • Integer
  • Float (floating point numbers - also called double)
  • Boolean
  • Array
  • Object
  • NULL
  • Resource


A string can be any text inside quotes. You can use single or double quotes:
Boolean

A Boolean represents two possible states: TRUE or FALSE.
Array

An array stores multiple values in one single variable.

In the following example $cars is an array. The PHP var_dump() function returns the data type and value:

<?php
$cars = array('Volvo','BMW','Toyota');
var_dump($cars);
?>

Strings

The PHP string functions are part of the PHP core. No installation is required to use these functions.

Function

Description
addcslashes()Returns a string with backslashes in front of the specified characters
addslashes()Returns a string with backslashes in front of predefined characters
bin2hex()Converts a string of ASCII characters to hexadecimal values
chop()Removes whitespace or other characters from the right end of a string
chr()Returns a character from a specified ASCII value
chunk_split()Splits a string into a series of smaller parts
convert_cyr_string()Converts a string from one Cyrillic character-set to another
convert_uudecode()Decodes a uuencoded string
convert_uuencode()Encodes a string using the uuencode algorithm
count_chars()Returns information about characters used in a string
crc32()Calculates a 32-bit CRC for a string
crypt()One-way string hashing
echo()Outputs one or more strings
explode()Breaks a string into an array
fprintf()Writes a formatted string to a specified output stream
get_html_translation_table()Returns the translation table used by htmlspecialchars() and htmlentities()
hebrev()Converts Hebrew text to visual text
hebrevc()Converts Hebrew text to visual text and new lines (n) into <br>
hex2bin()Converts a string of hexadecimal values to ASCII characters
html_entity_decode()Converts HTML entities to characters
htmlentities()Converts characters to HTML entities
htmlspecialchars_decode()Converts some predefined HTML entities to characters
htmlspecialchars()Converts some predefined characters to HTML entities
implode()Returns a string from the elements of an array
join()Alias of implode()
lcfirst()Converts the first character of a string to lowercase
levenshtein()Returns the Levenshtein distance between two strings
localeconv()Returns locale numeric and monetary formatting information
ltrim()Removes whitespace or other characters from the left side of a string
md5()Calculates the MD5 hash of a string
md5_file()Calculates the MD5 hash of a file
metaphone()Calculates the metaphone key of a string
money_format()Returns a string formatted as a currency string
nl_langinfo()Returns specific local information
nl2br()Inserts HTML line breaks in front of each newline in a string
number_format()Formats a number with grouped thousands
ord()Returns the ASCII value of the first character of a string
parse_str()Parses a query string into variables
print()Outputs one or more strings
printf()Outputs a formatted string
quoted_printable_decode()Converts a quoted-printable string to an 8-bit string
quoted_printable_encode()Converts an 8-bit string to a quoted printable string
quotemeta()Quotes meta characters
rtrim()Removes whitespace or other characters from the right side of a string
setlocale()Sets locale information
sha1()Calculates the SHA-1 hash of a string
sha1_file()Calculates the SHA-1 hash of a file
similar_text()Calculates the similarity between two strings
soundex()Calculates the soundex key of a string
sprintf()Writes a formatted string to a variable
sscanf()Parses input from a string according to a format
str_getcsv()Parses a CSV string into an array
str_ireplace()Replaces some characters in a string (case-insensitive)
str_pad()Pads a string to a new length
str_repeat()Repeats a string a specified number of times
str_replace()Replaces some characters in a string (case-sensitive)
str_rot13()Performs the ROT13 encoding on a string
str_shuffle()Randomly shuffles all characters in a string
str_split()Splits a string into an array
str_word_count()Count the number of words in a string
strcasecmp()Compares two strings (case-insensitive)
strchr()Finds the first occurrence of a string inside another string (alias of strstr())
strcmp()Compares two strings (case-sensitive)
strcoll()Compares two strings (locale based string comparison)
strcspn()Returns the number of characters found in a string before any part of some specified characters are found
strip_tags()Strips HTML and PHP tags from a string
stripcslashes()Unquotes a string quoted with addcslashes()
stripslashes()Unquotes a string quoted with addslashes()
stripos()Returns the position of the first occurrence of a string inside another string (case-insensitive)
stristr()Finds the first occurrence of a string inside another string (case-insensitive)
strlen()Returns the length of a string
strnatcasecmp()Compares two strings using a 'natural order' algorithm (case-insensitive)
strnatcmp()Compares two strings using a 'natural order' algorithm (case-sensitive)
strncasecmp()String comparison of the first n characters (case-insensitive)
strncmp()String comparison of the first n characters (case-sensitive)
strpbrk()Searches a string for any of a set of characters
strpos()Returns the position of the first occurrence of a string inside another string (case-sensitive)
strrchr()Finds the last occurrence of a string inside another string
strrev()Reverses a string
strripos()Finds the position of the last occurrence of a string inside another string (case-insensitive)
strrpos()Finds the position of the last occurrence of a string inside another string (case-sensitive)
strspn()Returns the number of characters found in a string that contains only characters from a specified charlist
strstr()Finds the first occurrence of a string inside another string (case-sensitive)
strtok()Splits a string into smaller strings
strtolower()Converts a string to lowercase letters
strtoupper()Converts a string to uppercase letters
strtr()Translates certain characters in a string
substr()Returns a part of a string
substr_compare()Compares two strings from a specified start position (binary safe and optionally case-sensitive)
substr_count()Counts the number of times a substring occurs in a string
substr_replace()Replaces a part of a string with another string
trim()Removes whitespace or other characters from both sides of a string
ucfirst()Converts the first character of a string to uppercase
ucwords()Converts the first character of each word in a string to uppercase
vfprintf()Writes a formatted string to a specified output stream
vprintf()Outputs a formatted string
vsprintf()Writes a formatted string to a variable
wordwrap()Wraps a string to a given number of characters




<?php
echo str_replace('world', 'Dolly', 'Hello world!'); // outputs Hello Dolly!
?>

PHP has two operators that are specially designed for strings.
.Concatenation$txt1 . $txt2Concatenation of $txt1 and $txt2
.=Concatenation assignment$txt1 .= $txt2Appends $txt2 to $txt1

<?php
$txt1 = 'Hello';
$txt2 = ' world!';
echo $txt1 . $txt2;
?>

define(name, value, case-insensitive)
<?php
define('GREETING', 'Welcome to Goa!');
echo GREETING;
?>

Constants are automatically global and can be used across the entire script.

Equal$x $yReturns true if $x is equal to $y
Identical$x $yReturns true if $x is equal to $y, and they are of the same type
!=Not equal$x != $yReturns true if $x is not equal to $y
<>Not equal$x <> $yReturns true if $x is not equal to $y
!Not identical$x ! $yReturns true if $x is not equal to $y, or they are not of the same type