Skip to content

Instantly share code, notes, and snippets.

View kodetop's full-sized avatar

Kodetop kodetop

View GitHub Profile
@kodetop
kodetop / functions.php
Last active June 25, 2023 03:50
Sintaxis wp_enqueue_style
// $handle: nombre del estilo (requerido)
// $src: ruta del archivo a incluir (requerido)
// $deps: nombre del estilo dependiente, se carga el dependiente previamente
// $ver: versión del archivo que vamos a incluir
// $media: media del estilo a incluir (‘all’, ‘screen’, ‘print’, ‘handheld’)
wp_enqueue_style( $handle, $src, $deps, $ver, $media );
@kodetop
kodetop / welcome.php
Last active August 16, 2020 18:05
Code Style: Ejemplo de usando PSR-1
<?php
require 'Kodetop/UserProfile.php';
use Kodetop\UserProfile;
$user = new UserProfile();
echo 'Hello ' . $user->getName();
@kodetop
kodetop / UserProfile.php
Created August 16, 2020 18:02
Code Style: Ejemplo usando PSR-1
<?php
namespace Kodetop;
class UserProfile
{
const VERSION = '1.0';
var $name = 'Guest';
function getName()
@kodetop
kodetop / user-profile.php
Last active August 16, 2020 18:18
Code Style: Ejemplo sin PSR-1
<?php
class user_profile
{
const version = '1.0';
var $name = 'Guest';
function GetName()
{
return $this->name;
@kodetop
kodetop / countries.php
Created March 31, 2020 04:11
PDO: Connection
<?php
// include connection
require 'pdo.php';
@kodetop
kodetop / countries.php
Created March 31, 2020 02:55
PDO: Countries
<ul>
<?php while (($result = $statement->fetch()) !== false): ?>
<li><a href="country.php?code=<?php echo $result->code; ?>"><?php echo $result->name; ?></a></li>
<?php endwhile; ?>
</ul>
@kodetop
kodetop / countries.php
Created March 31, 2020 02:53
PDO: Countries
<?php
// include connection
require 'pdo.php';
// prepare query
$statement = $pdo->prepare("SELECT * FROM country");
$statement->execute();
@kodetop
kodetop / country.php
Created March 31, 2020 02:51
PDO: Country
<h1>Country</h1>
<p>
<strong>Name</strong>: <?php echo $result->name; ?><br>
<strong>Continent</strong>: <?php echo $result->continent; ?><br>
<strong>Region</strong>: <?php echo $result->region; ?><br>
<strong>Population</strong>: <?php echo number_format($result->population); ?><br>
<strong>Area</strong>: <?php echo number_format($result->area); ?><br>
<strong>Head of State</strong>: <?php echo $result->headofstate; ?>
</p>
<p>
@kodetop
kodetop / country.php
Last active March 31, 2020 03:12
PDO: Country detail
<?php
// include connection
require 'pdo.php';
// get and filter parameter
$code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_STRING);
// prepare query
$statement = $pdo->prepare("SELECT * FROM country WHERE Code = :code");
$statement->bindValue(':code', $code, PDO::PARAM_STR);
@kodetop
kodetop / pdo-query.php
Created March 31, 2020 02:13
PDO: Query data
<?php
// include connection
require 'pdo.php';
// send query
$statement = $pdo->prepare("SELECT * FROM country");
$statement->execute();
// loop and print data
while (($result = $statement->fetch()) !== false) {