Today, I have started to learn PHP. And, I have created my first PHP file to test different variables. You can see my file as follows.
<?php $x = 5; // Global scope function myTest() { $y = 10; // Local scope echo "<p>Test variables inside the function:<p>"; echo "Variable x is: $x"; echo "<br>"; echo "Variable y is: $y"; } myTest(); echo "<p>Test variables outside the function:<p>"; echo "Variable x is: $x"; echo "<br>"; echo "Variable y is: $y"; ?>
I have found the following errors when I have run this file in the browser.
Notice: Undefined variable: x in /opt/lampp/htdocs/anand/php/index.php on line 19
Notice: Undefined variable: y in /opt/lampp/htdocs/anand/php/index.php on line 29
How can I fix the issue regarding it?
Related Posts:
- How do I get PHP errors to display?
- What’s the purpose of ini_set() in php? (especially for error reporting)
- PHP Notice: Undefined offset: 1 with array when reading data
- Notice: Trying to get property of non-object error
- What is unexpected T_VARIABLE in PHP?
- How do I get a YouTube video thumbnail from the YouTube API?
- How to avoid Request Entity Too Large 413 error
- Array to String PHP?
- Should I use mysqli_real_escape string() or mysql_real_escape_string() for form data?
- How to fix “Headers already sent” error in PHP
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- What are the main differences between PHPExcel and PhpSpreadsheet?
- PDOException: SQLSTATE[HY000] [2002] No such file or directory
- How do I get a file extension in PHP?
- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
- Convert a PHP object to an associative array
- XAMPP Port 80 in use by “Unable to open process” with PID 4
- How to parse a CSV file using PHP
- Cannot use object of type stdClass as array?
- Is a new line = \n OR \r\n?
- Regex to check for new line
- Email Not Sending from Byethost Hosting
- break out of if and foreach
- Redirect vs RedirectMatch
- Illegal string offset Warning PHP
- Can curl make a connection to any TCP ports, not just HTTP/HTTPS?
- mysqli_real_connect(): (HY000/2002): No such file or directory
- Deleting an element from an array in PHP
- Converting string to Date and DateTime
- Error 330 (net::ERR_CONTENT_DECODING_FAILED):
- What does __FILE__ mean?
- How can I do ‘insert if not exists’ in MySQL?
- Fatal error: Call to a member function bind_param() on boolean [duplicate]
- How do you parse and process HTML/XML in PHP?
- Is there a difference between the UTC and Etc/UTC time zones?
- Fatal error: Call to a member function prepare() on null
- PHP mail not working for some reason
- move_uploaded_file gives “failed to open stream: Permission denied” error
- PHP convert XML to JSON
- PHP if not statements
- PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client
- WordPress Error : Upload folder is not writable. Export and file upload features will not be functional
- How to call function of one php file from another php file and pass parameters to it?
- how to get id from URL using php
- Fatal error: Cannot use object of type mysqli_result
- mysql_field_name to the new mysqli
- MAMP “Apache couldn’t be started because port is in use.” AND “Can’t connect to local MySQL server through /tmp/mysql.sock
- mysqli_select_db() expects parameter 1 to be mysqli, string given
- Php include not working? function not being included
- PHP mail function doesn’t complete sending of e-mail
- Remove all special characters from a string
- Convert php array to Javascript
- how to convert object into string in php
- PHP Fatal error: Call to undefined function mssql_connect()
- phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user ‘pma’@’localhost’ (using password: NO)
- Call to a member function on null?
- how to ping ip addresses in php and give results
- do_shortcode not working
- SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102
- Only variable references should be returned by reference – Codeigniter
- PHP Unset Session Variable
- “Fatal error: Cannot redeclare function”
- php get all url variables
- How to remove unused dependencies from composer?
- how to get date of yesterday using php?
- phpinfo() is not working on my CentOS server
- How can I fetch all items from a DynamoDB table without specifying the primary key?
- ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it
- How to extract and access data from JSON with PHP?
- How to convert array to SimpleXML
- What does double question mark (??) operator mean in PHP
- How can I find the php.ini file used by the command line?
- WordPress query single post by slug
- TCPDF ERROR: Some data has already been output, can’t send PDF file
- Check if a PHP cookie exists and if not set its value
- Limit String Length
- How to run PHP locally on MacOS
- Call PHP function from jQuery?
- PhpMailer SMTP NOTICE: EOF caught while checking if connected
- Facebook – Error parsing input URL, no data was cached, or no data was scraped
- What is the meaning of sprintf(): Too few arguments
- How to use $_SERVER[‘HTTP_REFERER’] correctly in php?
- what is $_SERVER[‘QUERY_STRING’] ? how it works?
- PHP Error : Fatal error: Constant expression contains invalid operations
- JavaScript equivalent of PHP’s in_array()
- Paypal IPN Verification Postback with HTTPS
- Create a folder if it doesn’t already exist
- Implement linked list in php
- Using PHP 7 with WAMP
- Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
- PHP: date function to get month of the current date
- Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given… what I do wrong?
- PHP: bootstrap.php
- Display array values in PHP
- Php create a file if not exists
- Page redirect after certain time PHP
- Check if $_POST exists
- PHP & Case Sensitivity
- PHP Header redirect not working [duplicate]
- PHP – Fatal error: Unsupported operand types