Skip to content

[RFC] Remove PHP's short open tags in PHP 8 #3975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Zend/tests/bug55445.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Bug #55445 (Lexer error with short open tags)
--INI--
short_open_tag=0
--FILE--
<?php $u = "chris"; ?><p>Welcome <?= $u ?></p>
--EXPECT--
Expand Down
4 changes: 0 additions & 4 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,17 +511,14 @@ static FILE *zend_fopen_wrapper(const char *filename, zend_string **opened_path)
/* }}} */

#ifdef ZTS
static zend_bool short_tags_default = 1;
static uint32_t compiler_options_default = ZEND_COMPILE_DEFAULT;
#else
# define short_tags_default 1
# define compiler_options_default ZEND_COMPILE_DEFAULT
#endif

static void zend_set_default_compile_time_values(void) /* {{{ */
{
/* default compile-time values */
CG(short_tags) = short_tags_default;
CG(compiler_options) = compiler_options_default;
}
/* }}} */
Expand Down Expand Up @@ -1002,7 +999,6 @@ int zend_post_startup(void) /* {{{ */
*GLOBAL_CONSTANTS_TABLE = *executor_globals->zend_constants;
global_map_ptr_last = compiler_globals->map_ptr_last;

short_tags_default = CG(short_tags);
compiler_options_default = CG(compiler_options);

zend_destroy_rsrc_list(&EG(persistent_list));
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ struct _zend_compiler_globals {

zend_bool parse_error;
zend_bool in_compilation;
zend_bool short_tags;

zend_bool unclean_shutdown;

Expand Down
15 changes: 1 addition & 14 deletions Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -1947,19 +1947,6 @@ string:
RETURN_TOKEN(T_OPEN_TAG);
}


<INITIAL>"<?" {
if (CG(short_tags)) {
BEGIN(ST_IN_SCRIPTING);
if (PARSER_MODE()) {
SKIP_TOKEN(T_OPEN_TAG);
}
RETURN_TOKEN(T_OPEN_TAG);
} else {
goto inline_char_handler;
}
}

<INITIAL>{ANY_CHAR} {
if (YYCURSOR > YYLIMIT) {
RETURN_TOKEN(END);
Expand All @@ -1977,7 +1964,7 @@ inline_char_handler:
}

if (*YYCURSOR == '?') {
if (CG(short_tags) || !strncasecmp((char*)YYCURSOR + 1, "php", 3) || (*(YYCURSOR + 1) == '=')) { /* Assume [ \t\n\r] follows "php" */
if (!strncasecmp((char*)YYCURSOR + 1, "php", 3) || (*(YYCURSOR + 1) == '=')) { /* Assume [ \t\n\r] follows "php" */

YYCURSOR--;
break;
Expand Down
13 changes: 0 additions & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1000,19 +1000,6 @@ if test "$PHP_LIBGCC" = "yes"; then
PHP_ADD_LIBRARY(gcc, yes)
fi

PHP_ARG_ENABLE([short-tags],
[whether to enable short tags by default],
[AS_HELP_STRING([--disable-short-tags],
[Disable the short-form <? start tag by default])],
[yes],
[no])

if test "$PHP_SHORT_TAGS" = "yes"; then
AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, "1", [ ])
else
AC_DEFINE(DEFAULT_SHORT_OPEN_TAG, "0", [ ])
fi

PHP_ARG_ENABLE([dmalloc],
[whether to enable dmalloc],
[AS_HELP_STRING([--enable-dmalloc],
Expand Down
4 changes: 1 addition & 3 deletions ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ static int cli_is_valid_code(char *code, size_t len, zend_string **prompt) /* {{
}
break;
case outside:
if ((CG(short_tags) && !strncmp(code+i-1, "<?", 2))
|| (i > 3 && !strncmp(code+i-4, "<?php", 5))
) {
if (i > 3 && !strncmp(code+i-4, "<?php", 5)) {
code_type = body;
}
break;
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_basic1.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : basic functionality - with default arguments
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_basic2.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : basic functionality - with all arguments
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation10.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : usage variations - single quoted strings
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation11.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : obscure values within attributes
--INI--
short_open_tag = on
--FILE--
<?php

Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation2.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : usage variations - unexpected values for 'allowable_tags'
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation4.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : usage variations - invalid values for 'str' and valid 'allowable_tags'
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation5.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : usage variations - heredoc strings
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation6.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : usage variations - binary safe checking
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation7.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : usage variations - invalid values for 'str' and 'allowable_tags'
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation8.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : usage variations - valid value for 'str' and invalid values for 'allowable_tags'
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/tests/strings/strip_tags_variation9.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Test strip_tags() function : usage variations - double quoted strings
--INI--
short_open_tag = on
--FILE--
<?php
/* Prototype : string strip_tags(string $str [, string $allowable_tags])
Expand Down
Loading