I am trying to include a value from a database table in an input field value element.This is what I have, but it does not work:
?><input type="text" size="10" value="<?= date("Y-m-d", strtotime($rowupd['upcoming_event_featured_date'])) ?>" name="upcoming_event_featured_date" id="keys"/><?php
I have done this before, but usually print it like this:
print '<input type="text" size="10" value="'.date("Y-m-d", strtotime($rowupd['upcoming_event_featured_date'])).'" name="upcoming_event_featured_date" id="keys"/>';
What is a suitable way to do this without using print ''?
print ''
It is a good idea to always use full PHP tags, because it will cause your application to break if you switch to another server, or your config is changed to prevent short tags.
?> <input type="text" size="10" value="<?php echo(date("Y-m-d", strtotime($rowupd['upcoming_event_featured_date']))); ?>"name="upcoming_event_featured_date" id="keys"/><?php
Also note that you are missing ;the end of your PHP code.
;
PHP , echo() HTML, PHP HTML .
echo()
, , short_open_tag php.ini. <?=. , , , , , .
short_open_tag
<?=
, . . , :
$featured_date = date("Y-m-d",strtotime($rowupd['featured_date'])); ?><input type="text" value="<?=$featured_date?>" name="featured_date" /><?php
, , HTML. , script, HTML-, . , .
You can use the short_open_tag directive to include <? = shortcut for printing. A.
If this is not available, you must use either print or echo to accomplish this.
You can try:
ini_set('short_open_tag', true);
You can do
[...] ?><input type="text" size="10" value="<?php echo date("Y-m-d", strtotime($rowupd['upcoming_event_featured_date'])) ?>" name="upcoming_event_featured_date" id="keys"/> <?php [...]
if there is no PHP in your configuration short_open_tag.
Source: https://habr.com/ru/post/1698654/More articles:Do you find Scrum Nokia Test useful? - scrumПроблема HashSet - equals и hashCode with работают по-другому, чем я ожидал - javaRedirection by country? - web-applicationsWhat is a good editor for WYSIWYG for HTML? - htmlGet programmatic comments xml doc - xmlProperty Page Does Not Display in Visual Studio 2008 - visual-studio-2008How is the maximum size of a SOAP message determined? - soapThe default processor is XSLT IE6 - xmlAdditional VC6 settings include path using env vars? - preprocessorLisp интроспекция? когда вызывается функция и когда она выйдет - lispAll Articles