Wonderful World Of String Functions() in Php7 Lesson 12

String functions in Php7 are your arsenal for being a more efficient coder.  The possibilities are immense when it comes to string functions in Php7. Let’s take a look at some of the string functions in Php7.

Echo Is A Php String Function

Echo is one Php string function that you have already been using. Now you know what it is called. It’s a pretty powerful programming tool and you will use it often. We have used it several times in our website project that we are building together. If you need the files from the last lesson download them here. Here are the files for this lesson.

<?php echo 'Echo is a string function,'; ?>

Traditionally Learning About String Functions

Traditionally, when we think about creating a function we visualize this in our minds.

Only cool people share!

<?php function myFunction(){echo 'this is my function';}?>

However, like discussed in lesson 5 about Php7 functions we know there are literally thousands of them. These particular functions are just related to strings as discussed in lesson 10.

The Knitty Gritty of Php7 String Functions

There are 98 string functions that we can use. It would be very time consuming to go down through each and everyone and demonstrate how they are used. The purpose of leaning this way is to build a site as we go so you have a finished product at the end. Hopefully, you will not be bored out of your mind. 🙂

Php7 String Functions That You Will Actually Use

Our purpose here is to show you how to use the string functions in case you need them in the future. We are also going to implement them in our project. This way you can have a real life example of code and how it works. Let’s get some string functions that you will actually use in your projects.

Php7 String Function explode()

Do you like to blow things up? Well, you can use the Php7 string function explode(). The explode string function will turn the string into an array. This will be helpful when you are trying to get a piece of the string and not the whole thing.

Open up your Dreamweaver or other editor and create a new file called stringfunctions.php. Insert the following codes. Make sure you include your header and footer in the new file. Feel free to experiment like we did in the video.

<?php /EXPLODE TURNS STRING INTO AN ARRAY
$var = "I love PHP7";
$array=explode(" ",$var);
echo $array[0].$array[1].$array[2]; ?>

implode Php7 String Function

<?php //CONVERTS ARRAY INTO STRING
$var = array('PHP7','is','Awesome','Coding!');
echo implode(" ",$var); ?>

htmlspecialchars Php7 String Function

<?php $var = "This is some <strong>bold</strong> text.";
echo $var.'<br>';
echo htmlspecialchars($var); ?>

 

htmlspecialchars_decode Php7 String Function

<?php $vars = "This is some &lt;b&gt;bold&lt;/b&gt; text.";
echo htmlspecialchars_decode($vars); ?>

htmlentities Php7 String Function

<?php $var = '<a href="https://a1websitepro.com">php7 tutorials</a>';
echo htmlentities($var); ?>

str_replace Php7 String Function

<?php echo str_replace("ROCKS","IS AWESOME","PHP7 ROCKS!"); ?>

About Our Project Laying The Foundation

The object of our lessons is going to be a complete website in the end. The name of our project is going to be PennsylvaniaWild.org. This website will have many capabilities. It will have both a desktop and mobile version of the site. There will be capabilities to leave comments and send emails. We will have a Dashboard that will handle all the data that gets pulled into the site and more. The site will show our beautiful pictures Of wildlife in Pennsylvania and a great places to visit. In the end will be building a fully functional content management system. We will be going over SEO search engine optimization, share buttons for social media and more. You will graduate into a fully qualified web developer who can program in PHP7.

 

Wonderful World Of String Functions() in Php7 Lesson 12 was last modified: October 29th, 2021 by Maximus Mccullough
String Functions() in Php7

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.