Home >> Tutorials/FAQs >> Index

PHP Script Tutorials and Tips - 204 Entries

It doesn't matter whether you are a beginner or an experienced developer of PHP, browse through our PHP sample codes and programming tips. They will always help you to improve your skills and find some good ideas to solve your programming problems.

So far, Our PHP developers have written 204 PHP programming tips to share with you. Each one of them answers one commonly asked PHP programming question with a short, but precise and clear PHP script. More tips will be available soon. Please come back to visit this page again.

PHP Tutorials - Downloading and Installing PHP

PHP script tips for downloading and installing PHP binary version for Windows system.

  1. How To Download and Install PHP for Windows?
  2. How To Verify Your PHP Installation?
  3. Where Are PHP Configuration Settings Stored?
  4. How To Run a PHP Script?

More...

PHP Tutorials - Understanding String Literals and Operations

A collection of 14 tips on PHP string literals, operations and conversaion. Clear explanations and tutorial exercises are provided on single-quoted strings, double-quoted strings, string elements, concatenation, converting values to strings, converting strings to values.

  1. How Many Escape Sequences Are Recognized in Single-Quoted Strings?
  2. Can You Specify the "new line" Character in Single-Quoted Strings?
  3. What Are the Special Characters You Need to Escape in Double-Quoted Stings?
  4. How Many Escape Sequences Are Recognized in Double-Quoted Strings?
  5. How To Include Variables in Double-Quoted Strings?
  6. How Many Ways to Include Variables in Double-Quoted Strings?
  7. How Many Ways to Include Array Elements in Double-Quoted Strings?
  8. How To Access a Specific Character in a String?
  9. How To Assigning a New Character in a String?
  10. How To Concatenate Two Strings Together?
  11. How To Compare Two Strings with Comparison Operators?
  12. How To Convert Numbers to Strings?
  13. How To Convert Strings to Numbers?

More...

PHP Tutorials - PHP Built-in Functions for Strings

A collection of 19 tips on manipulating PHP strings. Clear answers are provided with tutorial exercises on string functions including strlen, trim, substr, chop, strpos, strcmp, split, etc.

  1. How To Count the Number of Characters in a String?
  2. How Many ways to Remove Leading and Trailing White Spaces?
  3. How To Remove the New Line Character from the End of a Text Line?
  4. How To Remove Leading and Trailing Spaces from User Input Values?
  5. How to Find a Substring from a Given String?
  6. What Is the Best Way to Test the strpos() Return Value?
  7. How To Take a Substring from a Given String?
  8. How To Replace a Substring in a Given String?
  9. How To Reformat a Paragraph of Text?
  10. How To Convert Strings to Upper or Lower Cases?
  11. How To Convert Leading Characters to Upper Case?
  12. How To Compare Two Strings with strcmp()?
  13. How To Convert Strings to Hex Numbers?
  14. How To Generate a Character from an ASCII Value?
  15. How To Convert a Character to an ASCII Value?
  16. How To Split a String into Pieces?
  17. How To Join Multiple Strings into a Single String?
  18. How To Apply UUEncode to a String?
  19. How To Replace a Group of Characters by Another Group?

More...

PHP Tutorials - Understanding PHP Arrays and Their Basic Operations

A collection of 11 tips on PHP array introduction. Clear answers are provided with tutorial exercises on declaring and creating arrays, assigning and retrieving array elements, identifying elements by keys and indexes, copying arrays.

  1. What Is an Array in PHP?
  2. How To Create an Array?
  3. How To Test If a Variable Is an Array?
  4. How To Retrieve Values out of an Array?
  5. What Types of Data Can Be Used as Array Keys?
  6. How Values in Arrays Are Indexed?
  7. Can You Add Values to an Array without Keys?
  8. Can You Copy an Array?
  9. How to Loop through an Array?
  10. How the Values Are Ordered in an Array?
  11. How To Copy Array Values to a List of Variables?

More...

PHP Tutorials - PHP Built-in Functions for Arrays

A collection of 19 tips on PHP functions on arrays. Clear answers are provided with tutorial exercises on searching keys and values, sorting arrays, merging two arrays, looping on array elements, expanding and truncating arrays.

  1. How To Get the Total Number of Values in an Array?
  2. How Do You Know If a Key Is Defined in an Array?
  3. How To Find a Specific Value in an Array?
  4. How To Get All the Keys Out of an Array?
  5. How To Get All the Values Out of an Array?
  6. How To Sort an Array by Keys?
  7. How To Sort an Array by Values?
  8. How To Join a List of Keys with a List of Values into an Array?
  9. How To Merge Values of Two Arrays into a Single Array?
  10. How To Use an Array as a Queue?
  11. How To Use an Array as a Stack?
  12. How To Randomly Retrieve a Value from an Array?
  13. How To Loop through an Array without Using "foreach"?
  14. How To Create an Array with a Sequence of Integers or Characters?
  15. How To Pad an Array with the Same Value Multiple Times?
  16. How To Truncate an Array?
  17. How To Join Multiple Strings Stored in an Array into a Single String?
  18. How To Split a String into an Array of Substring?
  19. How To Get the Minimum or Maximum Value of an Array?

More...

PHP Tutorials - Creating Your Own Functions

A collection of 19 tips on creating your own PHP functions. Clear answers are provided with tutorial exercises on defining functions, defining arguments, passing references, returning references, argument default values, etc.

  1. How To Define a User Function?
  2. How To Invoke a User Function?
  3. How To Return a Value Back to the Function Caller?
  4. How To Pass an Argument to a Function?
  5. How Variables Are Passed Through Arguments?
  6. How To Pass Variables By References?
  7. Can You Define an Argument as a Reference Type?
  8. Can You Pass an Array into a Function?
  9. How Arrays Are Passed Through Arguments?
  10. How To Pass Arrays By References?
  11. Can You Define an Array Argument as a Reference Type?
  12. How To Return an Array from a Function?
  13. What Is the Scope of a Variable Defined in a Function?
  14. What Is the Scope of a Variable Defined outside a Function?
  15. How To Access a Global Variable inside a Function?
  16. How Values Are Returned from Functions?
  17. How To Return a Reference from a Function?
  18. How To Specify Argument Default Values?
  19. How To Define a Function with Any Number of Arguments?

More...

PHP Tutorials - Reading and Writing Files

A collection of 14 tips on PHP functions on file input and output. Clear answers are provided with tutorial exercises on opening files for reading and writing, appending data to existing files, reading file by line or character, reading file in binary mode.

  1. How To Read a Text File into an Array?
  2. How To Read the Entire File into a Single String?
  3. How To Open a File for Reading?
  4. How To Open a File for Writing?
  5. How To Append New Data to the End of a File?
  6. How To Read One Line of Text from a File?
  7. How To Read One Character from a File?
  8. What's Wrong with "while ($c=fgetc($f)) {}"?
  9. How To Read a File in Binary Mode?
  10. How To Write a String to a File with a File Handle?
  11. How To Write a String to a File without a File Handle?
  12. How To Write an Array to a File without a File Handle?
  13. How To Read Data from Keyboard (Standard Input)?
  14. How To Open Standard Output as a File Handle?

More...

PHP Tutorials - Working with Directoris and Files

PHP scripts and tips on file systems, including creating and removing directories, copying and removing files, dumping directory contents for an array, parsing file path names, etc.

  1. How To Create a Directory?
  2. How To Remove an Empty Directory?
  3. How To Remove a File?
  4. How To Copy a File?
  5. How To Dump the Contents of a Directory into an Array?
  6. How To Read a Directory One Entry at a Time?
  7. How To Get the Directory Name out of a File Path Name?
  8. How To Break a File Path Name into Parts?

More...

PHP Tutorials - Processing Web Forms

A collection of 21 tips on process Web forms with PHP scripts. Clear explanations and tutorial exercises are provided on generating and processing Web forms, getting values out of $_REQUEST, processing multiple choices, removing slashes, adding multiple submit buttons, adding hidden values, processing original query string.

  1. How To Create a Web Form?
  2. What Are Form Input HTML Tags?
  3. How To Generate a Form?
  4. Where Is the Submitted Form Data Stored?
  5. How To Retrieve the Submitted Form Data?
  6. What Happens If an Expected Input Field Was Not Submitted?
  7. How To Avoid the Undefined Index Error?
  8. How To List All Values of Submitted Fields?
  9. What Are Input Values of SELECT Tags?
  10. How To Specify Input Values for Radio Buttons?
  11. How To Specify Input Values for Checkboxes?
  12. How To Retrieve Input Values for Checkboxes Properly?
  13. How To Supply Default Values for Text Fields?
  14. How To Remove Slashes on Submitted Input Values?
  15. How To Support Multiple Submit Buttons?
  16. How To Support Hidden Form Fields?
  17. How To Generate and Process a Form with the Same Script?
  18. How To Submit Values without Using a Form?
  19. How To Retrieve the Original Query String?
  20. How To Protect Special Characters in Query String?
  21. How To Support Multiple-Page Forms?

More...

PHP Tutorials - Understanding and Managing Cookies

A collection of 23 tips on understanding and managing cookies in PHP. Clear explanations and tutorial exercises are provided on setting and receiving cookies, creating and removing persistent cookies, specifying domain and path to restrict cookies, finding cookies in cookie files, cookie limitations.

  1. What Is a Cookie?
  2. How To Send a Cookie to the Browser?
  3. How To Receive a Cookie from the Browser?
  4. How To Test Cookies on a Web Server?
  5. What Is a Persistent Cookie?
  6. How To Set a Persistent Cookie?
  7. How To Test Persistent Cookies?
  8. How To Remove a Cookie?
  9. What Are Domain and Path Attributes for Cookies?
  10. How To Specify Domain and Path for a Cookie?
  11. What Is the Common Mistake When Setting Path and Domain on Temporary Cookies?
  12. How Cookies Are Transported from Servers to Browsers?
  13. How To View Cookie Header Lines?
  14. How Cookies Are Transported from Browsers to Servers?
  15. Where Are the Persistent Cookies Stored on Your Computer?
  16. How To Delete Cookie Files on Your Computer?
  17. How to View the Content of a Cookie File?
  18. How Does Firefox Manage Cookies?
  19. Where Does File Firefox Store Persistent Cookies?
  20. How Many Cookies Can You Set?
  21. How Large Can a Single Cookie Be?
  22. How Are Cookies Encoded During Transportation?
  23. How Can Other Webmaster Steal Your Cookies?

More...

PHP Tutorials - Understanding and Using Sessions

A collection of 19 tips on understanding and using sessions in PHP. Clear explanations and tutorial exercises are provided on starting and closing sessions, saving and retrieving values in sessions, deciding how session IDs to be transferred, deciding where to store session files, deciding when to expire session values, etc.

  1. What Is a Session?
  2. How To Turn on the Session Support?
  3. How To Save Values to the Current Session?
  4. How To Retrieve Values from the Current Session?
  5. What Is a Session ID?
  6. How To Retrieve the Session ID of the Current Session?
  7. What Are Options to Transfer Session IDs?
  8. How Session IDs Are Transferred on Your Web Server?
  9. How To Force the PHP Engine to Use Cookies to Transfer Session IDs?
  10. Is It More Secure to Use Cookies to Transfer Session IDs?
  11. Where Are Session Values Stored?
  12. What Is the Timeout Period on Session Values?
  13. How To Test the Session Garbage Collection Process?
  14. How To Set session.gc_maxlifetime Properly?
  15. How To Set session.gc_divisor Properly?
  16. How To Remove Values Saved in the Current Session?
  17. How To Determine If a Session Is New?
  18. How To Close a Session Properly?
  19. What Is session_register()?

More...

PHP Tutorials - Working with MySQL Database

A collection of 21 tips on working with MySQL database. Clear explanations and tutorial exercises are provided on connecting and selecting MySQL database, creating and dropping tables, inserting, updating, and deleting rows, selecting and looping through data rows, searching by key words, setting auto-increment IDs.

  1. How To Install MySQL Server?
  2. How To Use MySQL Command Line Interface?
  3. What Do You Need to Connect PHP to MySQL?
  4. How To Connect to MySQL from a PHP Script?
  5. How To Create a Database?
  6. How To Select an Exiting Database?
  7. How To Run a SQL Statement?
  8. How To Create a Table?
  9. How To Get the Number of Rows Selected or Affected by a SQL Statement?
  10. How To Insert Data into a Table?
  11. How To Insert Rows Based on SELECT Statements?
  12. What Is a Result Set Object?
  13. How To Query Tables and Loop through the Returning Rows?
  14. How To Update Existing Rows in a Table?
  15. How To Delete Existing Rows in a Table?
  16. How To Quote Text Values in SQL Statements?
  17. How To Quote Date and Time Values in SQL Statements?
  18. How To Perform Key Word Search in Tables?
  19. How To Query Multiple Tables Jointly?
  20. How To Set the ID Column as Auto-Incremented?
  21. How To Get the Last ID Assigned by MySQL?

More...

PHP Tutorials - Uploading Files to Web Servers

A collection of 12 tips on uploading files with PHP pages. Clear explanations and tutorial exercises are provided on creating file upload HTML tags, setting encoding type on HTML forms, getting uploaded file information, storing uploaded file in database.

  1. What Is File Upload?
  2. Which HTML Tag Allows Users to Specify a File for Uploading?
  3. How To Write the FORM Tag Correctly for Uploading Files?
  4. How To Get the Uploaded File Information in the Receiving Script?
  5. How To Process Uploaded Files?
  6. How To Move Uploaded Files To Permanent Directory?
  7. How To Detect File Uploading Errors?
  8. Why Do You Need to Filter Out Empty Files?
  9. How To Create a Table To Store Files?
  10. How To Upload Files into Database?
  11. What Are the File Upload Settings in Configuration File?
  12. How To Get the Technical Specifications for File Upload?

More...


Selected Developer Jobs:

More...