Can't execute php codes in ".php" files!

I’m getting the below warning while editing “.php” files!

'Expected tag name, got “?” instead! (Html doesn’t support processing instructions)"

Any solution?

What software are you using to edit the file? What is in the file? If you can show the file here, there is a code formatting mode to make it readable (see the toolbar).

File editor provided by 000webhost!

Simple code as easy as echo hello world is triggering the warning!

Hi @user4589!

You are receiving that error because echo is not a function but a language construct: it does not work in all single line statements. For statements such as yours it is better to use print("text here"); instead :wink:

OK. I just typed this into the editor:

<!DOCTYPE html>

<?php echo "Hello world"; ?>

And I don’t get the warning you do. Try pasting in the code I have supplied here - perhaps one of your characters is not correct e.g. an apostrophe is an oblique quote or something.

It should do.

Possibly in Python, but not in PHP! The brackets are unnecessary, and echo is the standard.

“echo” was working with no problem, the issue started today! “print” triggers the warning too!

The editor itself is treating .php files as .html files

" " triggers the warning too!

Another problem is that, when I right click the .php files, there is no “view” option!

“echo” was working with no problem, the issue started today! “print” triggers the warning too!
The editor itself is treating .php files as .html files

" " triggers the warning too!
Another problem is that, when I right click the .php files, there is no “view” option!

On my side everything works fine: no errors are being outputted neither on echo nor print nor on single/double quote. I think it’s just a temporary JS glitch. My advice would be to clear your browser cache, fully refresh the webpage and not to worry about it :slight_smile:

It should do.

It does on most, but not as the standard ‘function’ mode. An example would be on ternary:

($var) ? echo "true" : echo "false"; // does not work

echo ($var) ? "true" : "false"; // this one works

($var) ? print("true") : print("false"); // this one works -- with or without brackets; I got used with brackets :-)

Heh! echo is not meant to return a value, and I can assure you with a high degree of confidence, that seasoned PHP developers use echo.

It does. Use that, but drop the brackets around the first value; they are unnecessary.

Yes, but no-one writing modern PHP uses print(). It’s probably risky, too - people will start expecting print(2) to return the value they have supplied. It doesn’t, apparently it always returns 1. I had to look that up!

Hehe, I was going to post that too, but you anticipated me! I noticed that cache would be the problem because the issue did not occur while using FireFox in private mode! (Thanks anyway!)

But yet, When I right click some files, the “view” option does not appear! Any Solution?

Sem%20T%C3%ADtulo

“View” is above “Rename”, obscured in your screenshot. Are you using a mobile device? That would explain both problems, if so. What browser are you using?

1 Like

no, I’m using an 15.6 inch (1366 x 768) display laptop, FireFox!

I didn’t have this problem before!

The context menu option box should be movable to prevent such problems!

Double click on file to edit it.

@teodor, I really appreciate for your intention to help, but please, read more carefully for what people ask!

My issue is with “view” not “edit” option! (by double clicking I can “edit” files, not “view”!)

Thanks!

I have just checked and, as @halfer pointed out earlier, the “View” option is above “Rename”. Please scroll up to see all other options.

That’s the problem, when I scroll up nothing is scrolled up!

And the option box can’t even be moved or something like that!

Is there no solution for this? I’m constantly zooming my browser in/out in order to “view” option shows up in the screen when I right click files! Anybody?

Explain your problem in depth please :slight_smile:

What browser are you using; what is your screen rezolution and size?

1 Like