This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function truncate($str, $len, $end='') { | |
| return substr($str, 0, strrpos(substr($str, 0, $len), ' ')) . $end; | |
| } | |
| $mensagem = 'Este texto é muito grande e eu quero cortar sem cortar as palavras no meio'; | |
| echo truncate($mensagem, 5, '...'); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #menu_linha { list-style: none; position: relative; } | |
| #menu_linha li { display: inline; } | |
| #menu_linha li a { color: #676565; font:bold 13px arial, verdana; display: block; float: left; padding: 6px 10px 4px 10px; text-decoration: none; } | |
| #menu_linha li a:hover { color: #F27B21; } | |
| #magic-line { position: absolute; bottom: -22px; left: 0; width: 100px; height: 1px; background: #F27B21; } | |
| #menu_linha li.ativo a { color:#F27B21 !important; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function saudacao( $nome = '' ) { | |
| date_default_timezone_set('America/Sao_Paulo'); | |
| $hora = date('H'); | |
| if( $hora >= 6 && $hora <= 12 ) | |
| return 'Bom dia' . (empty($nome) ? '' : ', ' . $nome); | |
| else if ( $hora > 12 && $hora <=18 ) | |
| return 'Boa tarde' . (empty($nome) ? '' : ', ' . $nome); | |
| else | |
| return 'Boa noite' . (empty($nome) ? '' : ', ' . $nome); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function saudacao( $nome = '' ) { | |
| date_default_timezone_set('America/Sao_Paulo'); | |
| $hora = date('H'); | |
| if( $hora >= 6 && $hora <= 12 ) | |
| return 'Bom dia' . (empty($nome) ? '' : ', ' . $nome); | |
| else if ( $hora > 12 && $hora <=18 ) | |
| return 'Boa tarde' . (empty($nome) ? '' : ', ' . $nome); | |
| else | |
| return 'Boa noite' . (empty($nome) ? '' : ', ' . $nome); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var array = new Array(); | |
| array[0] = 'Usando'; | |
| array[1] = 'o'; | |
| array[2] = 'implode'; | |
| array[3] = 'do'; | |
| array[4] = 'PHP'; | |
| array[5] = 'no'; | |
| array[6] = 'JS'; | |
| var juntar = array.join(';'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var string = "Usando;o;explode;do;PHP;no;JS"; | |
| var retorno = string.split(";"); | |
| alert( retorno[0] ); // irá imprimir: Usando | |
| alert( retorno[1] ); // irá imprimir: o | |
| alert( retorno[2] ); // irá imprimir: explode | |
| alert( retorno[3] ); // irá imprimir: do | |
| alert( retorno[4] ); // irá imprimir: PHP | |
| alert( retorno[5] ); // irá imprimir: no | |
| alert( retorno[6] ); // irá imprimir: JS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Anti Injection | |
| * Verifica e Trata as informações | |
| * Autor: Danilo Iannone - [email protected] | |
| */ | |
| function anti_injection( $obj ) { | |
| $obj = preg_replace("/(from|alter table|select|insert|delete|update|where|drop table|show tables|#|*|--|\\)/i", "", $obj); | |
| $obj = trim($obj); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * JavaScript print_r | |
| * | |
| * PHP print JavaScript version | |
| * | |
| * @package print_r | |
| * @author Bruno Augusto | |
| * @version 0.1 | |
| * | |
| * @params string Input |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.onload = function() { | |
| var array = new Array('Teste 1', 'Teste 2', 'Teste 3',[['Teste 4', 'Teste 5'],['Teste 6','Teste 7',['Teste 8','Teste 9']]]) | |
| document.write( '<pre>' + print_r( array ) + '</pre>' ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| $(function(){ | |
| $('#form_contato').submit(function(){ | |
| var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/); | |
| var nome = $('#txt_nome').val(); | |
| var email = $('#txt_email').val(); | |
| if( nome == '' ) { alert('Preencha o campo nome'); return false; } | |
| if( email == '' || !er.test(email) ) { alert('Preencha o campo email corretamente'); return false; } |