Jump to content
xisto Community
Sign in to follow this  
Unholy Prayer

Php Strings Tutorial Using Strings To Avoid Repitition

Recommended Posts

One of the useful features of PHP is strings. You can use them to print a long text item that you may be posting more than once. It doesn't have to be long, though. Here is an example.

<?php

$motto = "Free Web Hosting, No Ads.";
$site = "Xisto";

?>

That bit of coding could be used in a piece of text such as:

<?php echo "Welcome to $site. "; ?>

You can also use strings to make database functions shorter or easier to read. I'll get into that later.

I hope this tutorial was helpful to you guys.

Share this post


Link to post
Share on other sites

Strings can also be created as arrays like this

<?php$information[name] = array (					"ivan" => "ivanovich", 					"marko" => "markovich", 					"petar" => "petrovich"					);	foreach ($information[name] as $key_name => $key_surname) {		echo '<b>Name: </b>'.$key_name.' <b>Surname: </b>'.$key_surname.'<br>';	}?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.