Skip to content
  • About Us
  • Contact Us
  • Privacy Policy
  • Disclaimer
  • Corona Virus Stats (Covid-19)
  • Work with us
  • FB
  • LinkedIn
  • Twitter
  • Instagram.com
Tekraze

Tekraze

Dive Into Technology

  • Guides
    • Developer Guide
    • PC Guide
    • Web Guide
    • Android Guide
    • Music
    • Tutorials
  • Feed
    • Tech News
    • Shared Tech
    • Gaming Videos
    • Unboxing videos
  • Forums
    • Android Apps
    • Angular Npm Packages
    • Useful Site Links
    • Tech Queries
    • Windows OS Help
    • Web Guide and Help
    • Android Os And Rooting
    • Jhipster Discussion
    • Git & GitHub forum
    • Open Source Forum
  • Work with us
  • Toggle search form
  • AI or artificial intelligence a contribution to a better future or just another trend?
    AI: a contribution to a better future or just another trend? Latest tech
  • Put your Imagination to work & win a chance to visit Google India 1
    Put your Imagination to work & win a chance to visit Google India Tech News
  • Alphabet of programming ;languages
    The Alphabet of Programming Languages Tech News
  • Microstft Dynamics 365 Cloud Tekraze
    Microsoft Dynamics 365 you need to know about Product Reviews
  • Aftermath of Taking Over Git by Microsoft 2
    Aftermath of Taking Over Git by Microsoft Tech News
  • Startups changing cleantech 🔌 Tech Feed
  • Understanding the concept of the cone, a geometrical three-dimensional figure
    Understanding the concept of the cone, a geometrical three-dimensional figure Tech News
  • OpenAI’s fiction-spewing AI is learning to generate images
    OpenAi’s fiction-spewing AI is learning to generate images Tech News
Variable & its Scope in PHP 3

Variable & its Scope in PHP

Posted on January 30, 2018 By RAHUL CHANANA 2 Comments on Variable & its Scope in PHP

To output the text we have seen that we printed a string “These are my Variable” with one echo command and variable in another command. But Sometimes you need to interpolate the variable in the long string then how you will do it, it can be performed in two ways as shown below:

<?php
$blogger_name=”Rahul Chanana”;
$blog=”Tekraze”;
$posts=5;
echo “This is $blogger_name from $blog, and this is my $posts th posts”;
?>

<?php
$blogger_name=”Rahul Chanana”;
$blog=”Tekraze”;
$posts=5;
echo ‘This is ‘.$blogger_name.’ from ‘. $blog.’, and this is my’.$posts.’ th posts’;
?>

Output:This is Rahul Chanana from Tekraze, and this is my 5 th post

Things Learned

  • A Text (called as the string in programming languages) can be created by enclosing symbols in ” ” or ‘ ‘.
  • If You want to print value of a variable then you can create it in two ways, by enclosing the variable in double quote as in snippet 2 or concatenation with string using dot operator as shown in snippet 3
  • Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it. Therefore PHP is a loosely Typed Language (doesn’t require any variable declaration before using it)

Rules for PHP variables:

  • A variable can have a short name (like x and y) or a more descriptive name (age, carName, total_volume).
  • A variable starts with the $ sign, followed by the name of the variable
  • A variable name must start with a letter or the underscore character
  • A variable name cannot start with a number
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case-sensitive ($age and $AGE are two different variables)
Content Protection by DMCA.com
Pages: 1 2 3
Developer Guide, PHP Tutorials, Tutorials, Web Guide Tags:local variable, Loosely typed Language, PHP, static Variable, variable, Variable scope

Post navigation

Previous Post: Workflow of Git
Next Post: IDE’s The Integrated Development Environment you need to know

Related Posts

  • A simple script to create Rest API in Python with Dockerization as Bonus
    A simple script to create Rest API in Python with Dockerization as Bonus Developer Guide
  • A Roadway to Learn Web Designing and Development 5
    A Roadway to Learn Web Designing and Development Web Guide
  • Why Python Programming? 6
    Why Python Programming? Uncategorized
  • An Introduction to Application Programming Interfaces (APIs) and Common Apps/Services That Use Them
    An Introduction to Application Programming Interfaces (APIs) and Common Apps Services That Use Them Developer Guide
  • Easy to use AI image generator Banner
    3 Easy-to-Use AI Image Generator: A Sure Way to Artistic Photos Web Guide
  • Install Ubuntu in Windows 10
    How to Install Ubuntu in Windows 10 Tutorials

Comments (2) on “Variable & its Scope in PHP”

  1. Saurabh says:
    April 3, 2020 at 7:20 pm

    Thanks for sharing the informative blog post. I have found here lots of interesting information for my knowledge I need. All the details you provide to us, it was very helpful and useful. Thanks for sharing this amazing post. I appreciate your efforts.
    Check out some latest Shopping Apps

    Reply
    1. Balvinder Singh says:
      April 3, 2020 at 7:24 pm

      Thanks Saurabh, share with others and keep visiting

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Advertisements

Subscribe to updates

Enter your email below to subscribe





Posts by Categories

Advertisements
  • The Importance of Website Design and Web Development Services for a Company Banner
    The Importance of Website Design and Web Development Services for a Company Developer Guide
  • Remote working apps
    5 Must-Have Remote Working Apps Web Guide
  • Linux Terminology basics you need to know
    Developer Terminology – you need to know Developer Guide
  • Synaptic package manager in linux basics linux guide part 3 banner
    Synaptic package manager in Linux infographics basic Linux tools guide part 3 Developer Guide
  • Top 10 Websites to pay electricity bill online 7
    Top 10 Websites to pay electricity bill online Guest posts
  • Cloud Gaming Services Banner
    13 cloud gaming services for gamers to play high end games in 2021 Gaming
  • Types of Programming - Difference you need to know 8
    Types of Programming – Difference you need to know Developer Guide
  • Speed up Windows using USB Drive as virtual memory with Readyboost
    Speed up Windows using a USB drive as virtual memory like a magic PC Guide

Affliate Links

Sell with Payhip

Earn with Magenet

Sell and Buy with Adsy

GainRock affiliate Program

Automatic Backlinks

Advertise with Anonymous Ads

accessily tekraze verificationIndian Blog Directory

Copyright © 2023 Tekraze.

Powered by PressBook News WordPress theme