Skip to main content

Testing variables with PHP

First, we'll take a look at how to display what's in your variables. We're going to be viewing our results on a web page.

So see if you can get this script working first, because it's the one we'll be building on. Using a text editor like Notepad, or your PHP software, type the following. (You can copy and paste it, if you prefer.

But you learn more by typing it out yourself - it doesn't really sink in unless you're making mistakes!)

<html>
<head>
<title>Variables - Some Practice</title>
</head>
<body>

<?php print("It Worked!"); ?>


</body>
</html>

J2program
Software Developer Ishan
When you've finished typing it all, save the page as variables.php. Then Run the script. Remember: when you're saving your work, save it to the WWW folder, as explained here.

To run the page, start your browser up and type this in the address bar:

 http://localhost/variables.php

If you've created a folder inside the www folder,
then the address to type in your browser would be something like: http://localhost/FolderName/variables.php

Comments

Popular posts from this blog

Nodejs Events

Events in Node.js The EventEmitter Object You can assign event handlers to your own events with the EventEmitter object. In the example below we have created a function that will be executed when a "scream" event is fired. To fire an event, use the  emit()  method. var events = require('events'); var eventEmitter = new events.EventEmitter();  //Create an event handler:  var myEventHandler = function () {   console.log('I hear a scream!');  }  //Assign the event handler to an event: eventEmitter.on('scream', myEventHandler);  //Fire the 'scream' event:  eventEmitter.emit('scream');

Variables in PHP

A variable is a storage area. You put things into your storage areas (variables) so that you can use and manipulate them in your programmers. Things you'll want to store are numbers and text. Variable in PHP You can't begin their names with an underscore (_), or a number. But most other characters are fine. Example 1 : A person is going to be collecting the books. But we can specify how many books he will be collecting. If you have five books   to give him, then you do the "Answer"   is like this: Answer is = 5 Books Ok, now going to the subject …   you're studying   PHP, so there's something missing. Two things, actually. First, your people (variables) need a dollar sign at the beginning (people are like that). So it would be this: $ books = 10 Examples 2 : try to do $books=10+20+30; What is your answer : answer must be 60 Example 3 : Test your mind Find the total books ? $english_book=10; ...

Family get-together with Ramadan Ifthar 2017

Family get-together with Ramadan Ifthar 2017