Saltar al contenido

cómo vincular un archivo php en el ejemplo de código html

Te sugerimos que revises esta respuesta en un entorno controlado antes de pasarlo a producción, un saludo.

Ejemplo 1: cargar php en html

//Safe as:
index.html
number.php

//HTML:

   
      Home
   
   
      

Phone Number

include('number.php') ?> //PHP: 4895553268; ?>

Ejemplo 2: enlace html

"https://www.google.com/">Visit googel.com!

Ejemplo 3: cómo vincular html con php

/* PHP code can be easily injected into a standard HTML page. As a rule,
 * files with mixed content of that kind have .phtml extention. The workflow
 * is the same as for pure .php scripts: one should setup web-server to 
 * handle .phtml files the same way it handles .php - .phtml should be passed
 * to PHP engine, and the outcome gotta be sent to a visitor. PHP will parse
 * the .phtml and process everything inside tags , ignoring the
 * rest. I.e. the php code pieces in .phtml will be replaced in outcome with
 * results of their processing, and HTML / CSS / JavaScript code in .phtml, 
 * as well as text content, will be displayed in browser as is. The one and
 * only strict rule - your .phtml mixes must always start with PHP tag 
 * sequence , otherwise they won't be preprocessed by PHP engine.
 */

/**
 * @category Template
 * @package Hello_World
 */

$tpl = 'Hello %s!';
  
?>

"en">

  <?php <span class="token function">printf</span><span class="token punctuation">(</span>$tpl<span class="token punctuation">,</span><span class="token string">'World'</span><span class="token punctuation">)</span><span class="token selector">; ?<span class="token combinator">></span></title<span class="token combinator">></span>
  <style<span class="token combinator">></span>
  body</span><span class="token punctuation"></span><span class="token property">text-align</span><span class="token punctuation">:</span> center<span class="token punctuation">;</span><span class="token punctuation"></span>
  </style>
</head>
<body>
  <h1><?php <span class="token function">printf</span><span class="token punctuation">(</span>
     $tpl<span class="token punctuation">,</span><span class="token string">'world of '</span> . <span class="token function">date</span><span class="token punctuation">(</span><span class="token string">'Y'</span><span class="token punctuation">)</span> . <span class="token string">', the wonderful future world'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> ?></h1>
</body>
</html>

<!-- In a browser this template will display "Hello world of <span class="token number">2021</span><span class="token punctuation">,</span>
     the wonderful future world!<span class="token string">" with "</span>Hello World!" in title --></code></pre>
<h4>Te mostramos las comentarios y valoraciones de los usuarios</h4></p><div class="1156288aeb31a138c38144f0e15ac7e5" data-index="3" style="float: none; margin:5px 0 5px 0; text-align:center;">
<!-- banner-square -->
<center><ins class="adsbygoogle square_ads" data-ad-client="ca-pub-9156923925267699" data-ad-slot="2153468894"></ins></center><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
</div>
<div class="1156288aeb31a138c38144f0e15ac7e5" data-index="3" style="float: none; margin:5px 0 5px 0; text-align:center;">
<!-- banner-square -->
<center><ins class="adsbygoogle square_ads" data-ad-client="ca-pub-9156923925267699" data-ad-slot="2153468894"></ins></center><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
</div>

<div class="1156288aeb31a138c38144f0e15ac7e5" data-index="4" style="float: none; margin:5px 0 5px 0; text-align:center;">
<!-- multiplex-ads -->
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-9156923925267699" data-ad-slot="3776158861"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
</div>

<div style="font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;"></div><div style="text-align:center" class="yasr-auto-insert-visitor"><!--Yasr Visitor Votes Shortcode--><div id='yasr_visitor_votes_7b4c0646569f6' class='yasr-visitor-votes'><div class="yasr-custom-text-vv-before yasr-custom-text-vv-before-38029">¡Haz clic para puntuar esta entrada!</div><div id='yasr-vv-second-row-container-7b4c0646569f6' 
                                        class='yasr-vv-second-row-container'><div id='yasr-visitor-votes-rater-7b4c0646569f6'
                                      class='yasr-rater-stars-vv'
                                      data-rater-postid='38029' 
                                      data-rating='0'
                                      data-rater-starsize='32'
                                      data-rater-readonly='false'
                                      data-rater-nonce='7cf512ebb3' 
                                      data-issingular='true'
                                    ></div><div class="yasr-vv-stats-text-container" id="yasr-vv-stats-text-container-7b4c0646569f6"><svg xmlns="https://www.w3.org/2000/svg" width="20" height="20" 
                                   class="yasr-dashicons-visitor-stats"
                                   data-postid="38029" 
                                   id="yasr-stats-dashicon-7b4c0646569f6">
                                   <path d="M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z"></path>
                               </svg><span id="yasr-vv-text-container-7b4c0646569f6" class="yasr-vv-text-container">(Votos: <span id="yasr-vv-votes-number-container-7b4c0646569f6">0</span>  Promedio: <span id="yasr-vv-average-container-7b4c0646569f6">0</span>)</span></div><div id='yasr-vv-loader-7b4c0646569f6' class='yasr-vv-container-loader'></div></div><div id='yasr-vv-bottom-container-7b4c0646569f6' 
                              class='yasr-vv-bottom-container'
                              style='display:none'></div></div><!--End Yasr Visitor Votes Shortcode--></div></p><div class="banner mobile"><div class=" ">
	
	</div>
	</div><div class="banner desktop"><div class=" ">
	
	</div>
	</div></p><hr><div class="tags"><span><b>Tags :</b></span><a href="https://foroayuda.es/tag/css-example/" rel="tag"> Css Example </a> / </div><hr><h4 style="text-align: center !important;">Utiliza Nuestro Buscador</h4><script async src="https://cse.google.com/cse.js?cx=a429be4a2ea07f9cf"></script><div class="gcse-search"></div><div class="crp_related     crp-text-only"><h3>Preguntas Relacionadas:</h3><ul><li><a href="https://foroayuda.es/como-vincular-css-a-html-en-el-ejemplo-de-codigo-vscode/"     class="crp_link post-38017"><span class="crp_title">cómo vincular css a html en el ejemplo de código vscode</span></a></li><li><a href="https://foroayuda.es/como-vincular-html-al-ejemplo-de-codigo-python/"     class="crp_link post-38022"><span class="crp_title">cómo vincular HTML al ejemplo de código Python</span></a></li><li><a href="https://foroayuda.es/como-vincular-entre-scss-y-ejemplo-de-codigo-html/"     class="crp_link post-38021"><span class="crp_title">cómo vincular entre scss y ejemplo de código html</span></a></li><li><a href="https://foroayuda.es/como-vincular-varias-paginas-html-ejemplo-de-codigo/"     class="crp_link post-38032"><span class="crp_title">cómo vincular varias páginas HTML ejemplo de código</span></a></li><li><a href="https://foroayuda.es/como-vincular-2-archivos-html-juntos-ejemplo-de-codigo/"     class="crp_link post-38014"><span class="crp_title">cómo vincular 2 archivos html juntos ejemplo de código</span></a></li><li><a href="https://foroayuda.es/como-vincular-dos-paginas-html-usando-un-ejemplo-de-codigo-de-boton/"     class="crp_link post-38019"><span class="crp_title">cómo vincular dos páginas html usando un ejemplo de código…</span></a></li><li><a href="https://foroayuda.es/como-vincular-un-boton-a-otra-pagina-en-el-ejemplo-de-codigo-html/"     class="crp_link post-38031"><span class="crp_title">cómo vincular un botón a otra página en el ejemplo de código…</span></a></li><li><a href="https://foroayuda.es/vincular-html-con-css-en-el-ejemplo-de-codigo-de-codigo-de-visual-studio/"     class="crp_link post-32496"><span class="crp_title">vincular html con css en el ejemplo de código de código de…</span></a></li><li><a href="https://foroayuda.es/vincular-a-otra-pagina-html-en-google-apps-script/"     class="crp_link post-32495"><span class="crp_title">Vincular a otra página HTML en Google Apps Script</span></a></li><li><a href="https://foroayuda.es/como-vincular-la-variable-estatica-del-componente-en-html-en-angular-2/"     class="crp_link post-38024"><span class="crp_title">¿Cómo vincular la variable estática del componente en HTML…</span></a></li><li><a href="https://foroayuda.es/vincular-un-archivo-qtdesigner-ui-a-python-pyqt/"     class="crp_link post-32498"><span class="crp_title">¿Vincular un archivo qtDesigner .ui a python/pyqt?</span></a></li><li><a href="https://foroayuda.es/como-vincular-un-archivo-javascript-externo-al-hacer-clic-en-el-boton/"     class="crp_link post-38028"><span class="crp_title">Cómo vincular un archivo javascript externo al hacer clic en…</span></a></li></ul><div class="crp_clear"></div></div>			
			
            	<div class="banner desktop">
		<div class="center fluid">
					</div>
	</div>
		<div class="banner mobile">
		<div class="center fluid">
					</div>
	</div>
				

            <footer class="entry-footer">

                
                                    <div id="comments" class="comments-area">
		<div id="respond" class="comment-respond">
		<h3>Deja una respuesta <small><a rel="nofollow" id="cancel-comment-reply-link" href="/como-vincular-un-archivo-php-en-el-ejemplo-de-codigo-html/#respond" style="display:none;">Cancelar la respuesta</a></small></h3><form action="https://foroayuda.es/wp-comments-post.php" method="post" id="commentform" class="comment-form" novalidate><p class="comment-notes"><span id="email-notes">Tu dirección de correo electrónico no será publicada.</span> <span class="required-field-message">Los campos obligatorios están marcados con <span class="required">*</span></span></p><textarea id="comment" name="comment" cols="45" rows="1" required></textarea><p class="comment-form-author"><label for="author">Nombre <span class="required">*</span></label> <input id="author" name="author" type="text" value="" size="30" maxlength="245" autocomplete="name" required /></p>
<p class="comment-form-email"><label for="email">Correo electrónico <span class="required">*</span></label> <input id="email" name="email" type="email" value="" size="30" maxlength="100" aria-describedby="email-notes" autocomplete="email" required /></p>
<p class="comment-form-url"><label for="url">Web</label> <input id="url" name="url" type="url" value="" size="30" maxlength="200" autocomplete="url" /></p>
<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes" /> <label for="wp-comment-cookies-consent">Guarda mi nombre, correo electrónico y web en este navegador para la próxima vez que comente.</label></p>
<p class="form-submit"><input name="submit" type="submit" id="submit" class="btn btn-primary" value="Publicar el comentario" /> <input type='hidden' name='comment_post_ID' value='38029' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
</p>
<!-- Honeypot Antispam plugin v.1.0.4 wordpress.org/plugins/honeypot-antispam/ -->
		<p class="antispam-group antispam-group-q" style="clear: both;">
			<label>Current ye@r <span class="required">*</span></label>
			<input type="hidden" name="antspm-a" class="antispam-control antispam-control-a" value="2024" />
			<input type="text" name="antspm-q" class="antispam-control antispam-control-q" value="1.0.4" autocomplete="off" />
		</p>
		<p class="antispam-group antispam-group-e" style="display: none;">
			<label>Leave this field empty</label>
			<input type="text" name="antspm-e-email-url-website" class="antispam-control antispam-control-e" value="" autocomplete="off" />
		</p>
</form>	</div><!-- #respond -->
	</div>
                
                
            </footer>

        </div>

        <aside id="secondary" class="widget-area entry-aside">
	<div class="widget-area-wrapper ">
		
		<section id="recent-posts-3" class="widget widget_recent_entries">
		<h4 class="widget-title n-m-t">Entradas recientes</h4>
		<ul>
											<li>
					<a href="https://foroayuda.es/como-se-abren-archivos-mat-en-octave/">¿Cómo se abren archivos .mat en Octave?</a>
									</li>
											<li>
					<a href="https://foroayuda.es/como-sangrar-formatear-una-seleccion-de-codigo-en-visual-studio-code-con-ctrl-shift-f/">Cómo sangrar/formatear una selección de código en Visual Studio Code con Ctrl + Shift + F</a>
									</li>
											<li>
					<a href="https://foroayuda.es/como-sangrar-el-bloque-de-codigo-en-python-ide-spyder/">cómo sangrar el bloque de código en Python IDE: Spyder?</a>
									</li>
					</ul>

		</section><section id="custom_html-7" class="widget_text widget widget_custom_html"><div class="textwidget custom-html-widget"><!-- aside-ads -->
<ins class="adsbygoogle aside_ads"
     style="display:block"
     data-ad-client="ca-pub-9156923925267699"
     data-ad-slot="5963338509"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script></div></section>	</div>
</aside><!-- #secondary -->
    </div>
</main>


<footer class="site-footer">
	<div class="container">
			<div class="widget-area-footer">

					<div class="widget-area">
				<section id="nav_menu-3" class="widget widget_nav_menu"><h4 class="widget-title n-m-t">Aviso Legal y Contacto</h4><div class="menu-footer-container"><ul id="menu-footer" class="menu"><li id="menu-item-59444" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59444"><a href="https://foroayuda.es/aviso-legal/">Aviso Legal</a></li>
<li id="menu-item-59442" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59442"><a href="https://foroayuda.es/politica-de-cookies/">Política de Cookies</a></li>
<li id="menu-item-59443" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59443"><a href="https://foroayuda.es/politica-de-privacidad/">Política de Privacidad</a></li>
<li class="menu-item">	<script>
		function orbital_expand_navbar() {

			var element = document.getElementById("search-navbar");

			if (element.classList.contains('expand-searchform')) {
				element.classList.remove("expand-searchform");
				return;
			}else {
				element.classList.add("expand-searchform");
				document.getElementById("search-input").focus();
			}

		}
	</script>
	<a href="#" onclick="orbital_expand_navbar()" class="text-center"><i class="fa fa-search fa-sm"></i></a>
	</li></ul></div></section>			</div>

		
					<div class="widget-area">
				<section id="text-5" class="widget widget_text"><h4 class="widget-title n-m-t">Sitemap</h4>			<div class="textwidget"><p><a href="https://foroayuda.es/sitemap_index.xml">Sitemap Principa</a>l</p>
<p><strong><a href="/categorias-de-la-web/">Categorías de la Web</a></strong></p>
</div>
		</section>			</div>

		
		
		
	</div>

		<div class="credits row">

			<p>Respuestas a preguntas comunes sobre programacion y tecnología</p>

	
</div>	</div>
</footer>


<!-- Site Overlay -->
<div class="site-overlay"></div>


		<script type="application/ld+json">
			{
				"@context": "http://schema.org",
				"@type": "WebSite",
				"name": "Foro Ayuda",
				"alternateName": "Respuestas a preguntas comunes sobre programacion y tecnología",
				"url": "https://foroayuda.es"
			}
		</script>

					<script type="application/ld+json">
				{
					"@context": "http://schema.org",
					"@type": "Article",
					"headline": "Te sugerimos que revises esta respuesta en un entorno controlado antes de Leer Más",
					"mainEntityOfPage": {
					"@type": "WebPage",
					"@id": "https://foroayuda.es/como-vincular-un-archivo-php-en-el-ejemplo-de-codigo-html/"
				},
				
			"datePublished": "2023-03-07",
			"dateModified": "2023-03-07",
			"author": {
			"@type": "Person",
			"name": "Alina Gallardo"
		},
		"publisher": {
		"@type": "Organization",
		"name": "Foro Ayuda"

					,
			"logo": {
			"@type": "ImageObject",
			"url": "https://foroayuda.es/wp-content/uploads/2023/03/cropped-logo-foro-ayuda.png"
		}

	}

}
</script>



<style id='yasrcss-inline-css' type='text/css'>

            .yasr-star-rating {
                background-image: url('https://foroayuda.es/wp-content/plugins/yet-another-stars-rating/includes/img/star_2.svg');
            }
            .yasr-star-rating .yasr-star-value {
                background: url('https://foroayuda.es/wp-content/plugins/yet-another-stars-rating/includes/img/star_3.svg') ;
            }

            .yasr-star-rating {
                background-image: url('https://foroayuda.es/wp-content/plugins/yet-another-stars-rating/includes/img/star_2.svg');
            }
            .yasr-star-rating .yasr-star-value {
                background: url('https://foroayuda.es/wp-content/plugins/yet-another-stars-rating/includes/img/star_3.svg') ;
            }
</style>
<script type="text/javascript" id="code-prettify-js-before">
/* <![CDATA[ */
var codePrettifyLoaderBaseUrl = "https:\/\/foroayuda.es\/wp-content\/plugins\/code-prettify\/prettify";
/* ]]> */
</script>
<script data-minify="1" type="text/javascript" src="https://foroayuda.es/wp-content/cache/min/1/wp-content/plugins/code-prettify/prettify/run_prettify.js?ver=1678572161" id="code-prettify-js" defer></script>
<script data-minify="1" type="text/javascript" src="https://foroayuda.es/wp-content/cache/min/1/wp-content/plugins/honeypot-antispam/js/honeypot-antispam.js?ver=1678572161" id="honeypot-antispam-script-js" defer></script>
<script type="text/javascript" src="https://foroayuda.es/wp-content/themes/orbital/assets/js/navigation.js" id="orbital-navigation-js" defer></script>
<script type="text/javascript" src="https://foroayuda.es/wp-content/themes/orbital/assets/js/social.min.js" id="orbital-social-js" defer></script>
<script data-minify="1" type="text/javascript" src="https://foroayuda.es/wp-content/cache/min/1/wp-content/themes/orbital/assets/js/main.js?ver=1678572162" id="orbital-main-js" defer></script>
<script type="text/javascript" src="https://foroayuda.es/wp-content/plugins/machete/inc/social/js/share.min.js" id="machete_social-js" defer></script>
<script type="text/javascript" id="q2w3_fixed_widget-js-extra">
/* <![CDATA[ */
var q2w3_sidebar_options = [{"sidebar":"posts","use_sticky_position":false,"margin_top":10,"margin_bottom":0,"stop_elements_selectors":"comments","screen_max_width":800,"screen_max_height":0,"widgets":["#custom_html-7"]}];
/* ]]> */
</script>
<script type="text/javascript" src="https://foroayuda.es/wp-content/plugins/q2w3-fixed-widget/js/frontend.min.js" id="q2w3_fixed_widget-js" defer></script>
<script type="text/javascript" id="yasr-window-var-js-extra">
/* <![CDATA[ */
var yasrWindowVar = {"siteUrl":"https:\/\/foroayuda.es","adminUrl":"https:\/\/foroayuda.es\/wp-admin\/","ajaxurl":"https:\/\/foroayuda.es\/wp-admin\/admin-ajax.php","visitorStatsEnabled":"yes","ajaxEnabled":"yes","loaderHtml":"<div id=\"yasr-loader\" style=\"display: inline-block\">\u00a0 <img src=\"https:\/\/foroayuda.es\/wp-content\/plugins\/yet-another-stars-rating\/includes\/img\/loader.gif\" \n                 title=\"yasr-loader\" alt=\"yasr-loader\" height=\"16\" width=\"16\"><\/div>","loaderUrl":"https:\/\/foroayuda.es\/wp-content\/plugins\/yet-another-stars-rating\/includes\/img\/loader.gif","isUserLoggedIn":"false","isRtl":"false","starSingleForm":"\"estrella\"","starsPluralForm":"\"estrellas\"","textAfterVr":"\"(Votos: %total_count%  Promedio: %average%)\"","textRating":"\"Valoraci\\u00f3n\"","textLoadRanking":"\"Cargando por favor espere\"","textVvStats":"\"de 5 estrellas\"","textOrderBy":"\"Ordenar por\"","textMostRated":"\"Mayor puntuaci\\u00f3n\"","textHighestRated":"\"Mejor puntuaci\\u00f3n\"","textLeftColumnHeader":"\"Enrada\""};
/* ]]> */
</script>
<script type="text/javascript" src="https://foroayuda.es/wp-content/plugins/wp-rocket/assets/js/heartbeat.js" id="heartbeat-js" defer></script>
<script data-minify="1" type="text/javascript" src="https://foroayuda.es/wp-content/cache/min/1/wp-content/plugins/yet-another-stars-rating/includes/js/yasr-globals.js?ver=1678572162" id="yasr-global-functions-js" defer></script>
<script type="text/javascript" src="https://foroayuda.es/wp-content/plugins/yet-another-stars-rating/includes/js/tippy.all.min.js" id="tippy-js" defer></script>
<script data-minify="1" type="text/javascript" src="https://foroayuda.es/wp-content/cache/min/1/wp-content/plugins/yet-another-stars-rating/includes/js/shortcodes/visitorVotes.js?ver=1678572162" id="yasr-front-vv-js" defer></script>
<script>window.lazyLoadOptions={elements_selector:"img[data-lazy-src],.rocket-lazyload",data_src:"lazy-src",data_srcset:"lazy-srcset",data_sizes:"lazy-sizes",class_loading:"lazyloading",class_loaded:"lazyloaded",threshold:300,callback_loaded:function(element){if(element.tagName==="IFRAME"&&element.dataset.rocketLazyload=="fitvidscompatible"){if(element.classList.contains("lazyloaded")){if(typeof window.jQuery!="undefined"){if(jQuery.fn.fitVids){jQuery(element).parent().fitVids()}}}}}};window.addEventListener('LazyLoad::Initialized',function(e){var lazyLoadInstance=e.detail.instance;if(window.MutationObserver){var observer=new MutationObserver(function(mutations){var image_count=0;var iframe_count=0;var rocketlazy_count=0;mutations.forEach(function(mutation){for(var i=0;i<mutation.addedNodes.length;i++){if(typeof mutation.addedNodes[i].getElementsByTagName!=='function'){continue}
if(typeof mutation.addedNodes[i].getElementsByClassName!=='function'){continue}
images=mutation.addedNodes[i].getElementsByTagName('img');is_image=mutation.addedNodes[i].tagName=="IMG";iframes=mutation.addedNodes[i].getElementsByTagName('iframe');is_iframe=mutation.addedNodes[i].tagName=="IFRAME";rocket_lazy=mutation.addedNodes[i].getElementsByClassName('rocket-lazyload');image_count+=images.length;iframe_count+=iframes.length;rocketlazy_count+=rocket_lazy.length;if(is_image){image_count+=1}
if(is_iframe){iframe_count+=1}}});if(image_count>0||iframe_count>0||rocketlazy_count>0){lazyLoadInstance.update()}});var b=document.getElementsByTagName("body")[0];var config={childList:!0,subtree:!0};observer.observe(b,config)}},!1)</script><script data-no-minify="1" async src="https://foroayuda.es/wp-content/plugins/wp-rocket/assets/js/lazyload/17.5/lazyload.min.js"></script>
</body>
</html>
<!-- This website is like a Rocket, isn't it? Performance optimized by WP Rocket. Learn more: https://wp-rocket.me - Debug: cached@1727400267 -->