NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
[explained] Wrong ERROR


Joined: 05 May 2018
Posts: 29
Reply with quote
PhpED editor wrong alert.
It is not error...

PhpED Editor (unexpected end of file), but Webuilder2018 IDE display correct:


View user's profileFind all posts by gutapetruSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7889
Reply with quote
This is not an error per se, although it underlined the place that may work in some extents.
For example, if $row contains no fields or $row['culoare'] is empty, what will be produced in the output?
Anything but a correct HTML, right?
If really you need to mix HTML, CSS (or JS) with PHP, it's safer to do it in the following way:
Code:

<span class="categunderline" <?php if (isset($row["culoare"])) echo "style=color:".$row["culoare"].";"; ?>>


Also, I want to add that this mix does not scale good if your server is accessed by growing number of users. I'd recommend to stop using php in html/js/css generation. Use it to maintain sessions and fetch data, retrieve this data and in your js script and update static HTML. In this case server load will be much lower and it will scale better.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 05 May 2018
Posts: 29
Reply with quote
If this error persist and there is no fix I cannot use PhpED.
Dmitri, why do you delete my comment? They are not offensive.
View user's profileFind all posts by gutapetruSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7889
Reply with quote
please find a better place to promote our competitors.
As of the underlining marks, we'll try to add an option to suppress them -- that's exactly what other editors do. They hide such things. To illustrate that try to replace your php code chunk with something that for sure do not produce any output. You won't get any errors/warnings in that editors too, but this is an error.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 05 May 2018
Posts: 29
Reply with quote
dmitri wrote:
please find a better place to promote our competitors.
As of the underlining marks, we'll try to add an option to suppress them -- that's exactly what other editors do. They hide such things. To illustrate that try to replace your php code chunk with something that for sure do not produce any output. You won't get any errors/warnings in that editors too, but this is an error.

I purchased PhpED, and I like to help you and myself to have a very good product. I do not promote any competitors. It is a non sense.
How can I prove that is a bug in PhpED editor? Only if I test with other IDE's, right?
View user's profileFind all posts by gutapetruSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7889
Reply with quote
you don't need to prove anything.
Like I said, we'll try to add option to suppress that spots. It will work for you, right?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 05 May 2018
Posts: 29
Reply with quote
dmitri wrote:
you don't need to prove anything.
Like I said, we'll try to add option to suppress that spots. It will work for you, right?

Right!
View user's profileFind all posts by gutapetruSend private message
Guru master

Joined: 24 Jul 2009
Posts: 730
Reply with quote
I see what Dmitri is getting at and agree with him. The PhpED parser probably correctly ignores the <? ?> when parsing the HTML so you effectively have:

Code:
style="color:"


And that is indeed an error. Whilst 'unexpected end of file' is misleading, PhpED is correct in highlighting an issue. Just because you used PHP there does not mean the HTML parser can make any assumptions about what value that PHP may (not) generate.

I just checked a few common framework templates and all of them do either use PHP conditionals around the whole style attribute (so PhpED would not check it) or they get the styles from a complete variable/method and use that instead:

Code:
<th style="<?php echo $this->getTotalStyle() ?>">

<li <?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>>


Both of those methods means PhpED does not show errors.
View user's profileFind all posts by plugnplaySend private message


Joined: 05 May 2018
Posts: 29
Reply with quote
The code is correct. The settings in PhpED are right. Why is the error?



I am right !
View user's profileFind all posts by gutapetruSend private message
Guru master

Joined: 24 Jul 2009
Posts: 730
Reply with quote
PhpED has various different parsers. Two of them are for HTML and PHP. The HTML parser might also check CSS styles, although CSS is technically a third parser.

When parsing HTML, the PHP portion is ignored and effectively blanked out.

If you type:

Code:
<p style="color:<?php echo '#000' ?>;">


The PHP parser sees and checks the PHP part.

Code:
<?php echo '#000' ?>


The HTML parser checks the HTML part and in this case also checks the CSS syntax:

Code:
<p style="color:;">


That is a CSS style error and PhpED correctly shows it as an error. As Dmitri suggests, he can change PhpED to do something different in this situation so it is not highlighted as a CSS style error, but there is no doubt that it really is a CSS style error.

I agree with you that when using this sort of code format that might be annoying, but it is correct of PhpED to do that. That is why a different coding format can work around the issue.

What some code HTML validators do is change embedded PHP to something else during validation, because replacing PHP with an innocuous sequence that can minimize errors, but it is still hiding an error which technically is still there.
View user's profileFind all posts by plugnplaySend private message


Joined: 05 May 2018
Posts: 29
Reply with quote
Thanks plugnplay, I appreciate your effort.
I'll take time to study this.
Thanks to Dmitri too.
View user's profileFind all posts by gutapetruSend private message


Joined: 05 May 2018
Posts: 29
Reply with quote
Plugnplay, you are good as a teacher. :)
View user's profileFind all posts by gutapetruSend private message
[explained] Wrong ERROR
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic