[resolved]Notice: Use of undefined constant – php

In this post we will show you solution or how to resolve Notice of [resolved]Notice: Use of undefined constant, hear for Notice [resolved]Notice: Use of undefined constant we will give you for how to resolve Notice.

[resolved]Notice: Use of undefined constant
[resolved]Notice: Use of undefined constant

If you got this Notice PHP is writing this error show: “Notice: Use of undefined constant” then you need to read this post.

The blunder message is because of the appalling truth that PHP will verifiably pronounce an obscure token as a steady string of a similar name.

That is, it’s endeavoring to decipher this (take note of the missing quote marks):

echo $_POST[onlinecode];


echo $_POST['onlinecode'];

The main substantial way this would be legitimate punctuation in PHP is if there was already a steady division characterized. So unfortunately, as opposed to passing on with a Fatal blunder now, it issues this Notice and goes about as if a steady had been characterized with a similar name and esteem:

//Implicit statement of steady called office with esteem "office" 

define('onlinecode', 'onlinecode');   

There are different ways you can get this blunder message, however they all have a similar underlying driver – a token that could be a consistent.

Strings missing quotes('): $set_array[bad_key]

This is the thing that the issue is for your situation, and this is on account of you have string cluster keys that haven’t been cited. Settling the string keys will settle the bug:

Need Change Form ::

$onlinecode_val = mysql_real_escape_string($_POST[onlinecode]);

To This ::

// add single quotes
$onlinecode_val = mysql_real_escape_string($_POST['onlinecode']);

Variable missing dollar sign: var_without_dollar ($)

Another reason you may see this mistake message is whether you leave off the $ from a variable, or $this-> from a part. Example, both of the accompanying would cause a comparable blunder message:

set_local;   // you should be use $set_local
set_member;  // you should be use $this->set_member

Invalid character in factor name: $bad-variable-name

A comparative yet more unpretentious issue can come about on the off chance that you endeavor to utilize a denied character in a variable name - a hyphen (- ) rather than an underscore _ would be a typical case.

For instance, this is OK, since underscores are permitted in factor names:

if (123 === $my_var) { 



Be that as it may, this isn’t:

if (123 === $my_var) {

It’ll be deciphered the same as this:

if (123 === $my_var) {
	//variable $my less consistent "var" 



Alluding to a class steady without determining the class scope

Keeping in mind the end goal to allude to a class consistent you have to determine the class scope with ::, on the off chance that you miss this off PHP will believe you’re discussing a worldwide characterize().


class TestClass {
	const CONST_VAl = 116;

	public function set_method() {
		return self::CONST_VAl;  
		// This is work fine

	public function set_method() {
		return TestClass::CONST_VAl;  
		// This is work fine

	public function set_bad_method() {
		return CONST_VAl;  
		// This is BUG - we need to specify class scope

Utilizing a consistent that is not characterized in this form of PHP, or is characterized in an expansion that is not introduced

There are some framework characterized constants that exclusive exist in fresher forms of PHP, for instance the mode choice constants for round(), for example, PHP_ROUND_HALF_DOWN just exist in PHP 5.3 or later.

So in the event that you attempted to utilize this component in PHP 5.2, say:

$rounded_number = round($set_var, 0, PHP_ROUND_HALF_DOWN);

You’d get this mistake message:

Utilization of unclear consistent PHP_ROUND_HALF_DOWN - accepted "PHP_ROUND_HALF_DOWN" 
Warning (2): Wrong parameter mean round()

Hope this code and post will helped you for implement [resolved]Notice: Use of undefined constant. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org