include in php code example

Example 1: php check if string contains word

$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
    echo "My string contains Bob";
}

Example 2: include php

<?php
	include 'archive.php';
?>

Example 3: include and require in php

// Include a file, if it can't be found: continue.
<?php
include 'mainfile.php';
?>
  
// Alternatively: Require a file to be imported or quit if it can't be found
<?php
 require 'requiredfile.php';
?>

Example 4: require in php

// Require a file to be imported or quit if it can't be found
<?php
 require 'requiredfile.php';
?>

Example 5: how to use include in php

<?php
     include 'config.php';
?>

Tags:

Php Example